Popping up windows from a SharePoint webpart
I'm trying to pop a window up, from inside a procedure running in SharePoint. I need to pass a parameter to the URL, and have been trying to run the f开发者_如何学编程ollowing, however, the popup never pops up.
string sURL="http://myserver/mypage.aspx?param1=abc";
Response.Write("script LANGUAGE=\"Javascript\">\n");
Response.Write("window.open(\""+sUrl +"\", \"\", \"width=300, height=100\")");
Response.Write("<//script");
Can you help ?
Cheers
Nick
A couple of things:
- Your opening script tag is missing a < (opening angle bracket.).
- You don't need the \n at the end of that line.
- Your window.open command should have a ; at the end. (For completeness.)
- Your closing script tag does not need a double //
- Your closing script tag needs a closing > bracket. (Thanks OedipusPrime)
I believe that should fix it, it was probably the opening angle bracket which was the problem. However you should probably use ClientScript.RegisterStartupScript instead.
You should take a look at this MSDN article.
As the above poster stated, the script you're attempting to write out has various errors (you're also missing a > in the closing script tag), but more importantly you should be using the ASP.Net object model for injecting the Javascript on the page.
精彩评论