遇到自动跳转时要弹出网页,就发现出现了问题。后发现有这样的情况:
//这样注册的脚本会被阻止:
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "window.open('http://www.xxxxxxxxx.com');", true);
//客户端由用户触发的不会被阻止,即使设置阻止程序.
obj.οnclick=window.open("http://www.xxxxxxxxx.com")
1、放到连接里,然后用JS伪协议打开就好了
<a href='javascript:void window.open("x.html","x","resizable,width=600,height=450")'>不会被阻止</a>
2、登录窗口前一页Login0.aspx页面添加如下代码,
<a href="javascript:void window.open('Login.aspx','','width=1014px,height=703px,scrollbars=yes,left=0,top=0')">汽车租赁管理系统</a>
3、代码页添加
Response.Write("<script language='javascript'>window.open('Login.aspx','_self','')</script>");
4、在登录成功后
Response.Write("<script language='javascript'>window.open('Default.aspx','_blank','width=1014px,height=703px,scrollbars=yes,left=0,top=0');window.close();</script>");
5、
function openwin(url) {
var a = document.createElement("a");
a.setAttribute("href", url);
a.setAttribute("target", "_blank");
a.setAttribute("id", "openwin");
document.body.appendChild(a);
a.click();
}
<input type="button" id="btn" value="百度" οnclick="openwin('http://www.baidu.com');" />