在每次提交时启动一个新的IE窗口
问题描述:
我有一个asp.net“搜索”屏幕,当用户按下提交按钮时,在新的浏览器窗口中显示结果。在每次提交时启动一个新的IE窗口
我的问题是:
- 用户搜索“史密斯”,冲床提交,得到一个新的结果窗口,在“史密斯”的结果
- 用户搜索“棕色”,冲床提交。 ,并且之前的结果窗口被重用。
这是我叫的OnSubmit代码:
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);
我怎样才能得到,每次一个新窗口?
由于提前,
吉姆
答
尝试指定的窗口,而不是“键”
答
首先,你不需要用JS提交到一个新的窗口。您可以使用
<form target="_blank"> ... </form>
使用此表格将始终提交到新窗口。
如果您必须使用您具有的脚本,只需删除第二个参数open()
(使其为空)。第二个参数是您创建窗口的名称。所以当你再次调用它时,它会重新使用具有相同名称的窗口。
答
传中,主要作为查询字符串的名称为“_blank”,并传递null对window.open的第二个参数。
例:
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);