我在页面加载期间运行此脚本,但它当然会被阻止(弹出窗口)。 无法使用click事件,因此我需要在onload期间使用它。
有什么想法吗?
Page.ClientScript.RegisterStartupScript(this.GetType(), "win", "window.open('" + url + "');", true);
答案 0 :(得分:0)
尝试以下功能:
Public Shared Function WindowScript( URL As String, Name As String, Width As String, Height As String, MenuBar As Boolean, Toolbar As Boolean, Location As Boolean, StatusBar As Boolean, Copyhistory As Boolean, ScrollBar As Boolean, Resizable As Boolean) As String
Dim ret As String = "var left = (screen.width/2)-(" + Width + "/2); var top = (screen.height/2)-(" + Height + "/2); javascript:void window.open ('"
ret = ret & URL & "', '" & Name & "', '"
ret = ret & "resizable=1,"
ret = ret & "width=" & Width & ","
ret = ret & "height=" & Height & ","
ret = ret & "resizable=" & (If((Resizable), "1", "0")) & ","
ret = ret & "menuBar=" & (If((MenuBar), "1", "0")) & ","
ret = ret & "toolbar=" & (If((Toolbar), "1", "0")) & ","
ret = ret & "location=" & (If((Location), "1", "0")) & ","
ret = ret & "statusBar=" & (If((StatusBar), "1", "0")) & ","
ret = ret & "copyhistory=" & (If((Copyhistory), "1", "0")) & ","
ret = ret & "scrollBar=" & (If((ScrollBar), "1", "0")) & ","
ret = ret & "scrollbars=" & (If((ScrollBar), "yes", "no")) & ","
ret = ret & ",top='+top+',left='+left)"
Return ret
End Function
这适用于任何浏览器。