开发者

Launch a new IE window on each submit

I have an asp.net "search" screen which displays the results in a new browser window ewhen the user presses the submit button.

My problem is as follows:

  1. User searches for "smith", presses submit, gets a new results window with "smith" results in.
  2. User searches for "brown", presses submit, and the previous results window is reused.

Here's the code I call OnS开发者_C百科ubmit:

string strScript = "window.open('searchresults.aspx', 'Key', 'height=500,width=800,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,titlebar=yes');";
        ScriptManager.RegisterStartupScript(this, typeof(string), uniqueKey, strScript, true);

How can I get a new window each time?

Thanks in advance,

Jim


First, you don't need to use JS to submit to a new window. You can just use

<form target="_blank"> ... </form>

Using this the form will always be submitted to a new window.

If you must use the script you have, just remove the second parameter to open() (make it null). That second parameter is a name for the window you create. So you when you call it again, it'll reuse the window with the same name.


Try specifying '_blank' for the name of the window instead of 'Key'


Pass in the Key as a query string and pass null to the second parameter to window.open.

Ex:

string strScript = "window.open('searchresults.aspx?key=smith', null, 'height=500,width=800,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,titlebar=yes');";
        ScriptManager.RegisterStartupScript(this, typeof(string), uniqueKey, strScript, true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜