我有樣品asp.net按鈕,我正在寫點擊事件,並試圖打開一個新的popupwindow,出於某種原因彈出窗口不打開,請我可以知道問題是否與瀏覽器或代碼彈出窗口無法打開按鈕點擊在asp.net
Test.aspx的
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function openNewWin(url) {
var x = window.open(url, 'mynewwin', 'width=600,height=600,toolbar=1');
x.focus();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnOpenPop" runat="server" Text="Open Pop"
onclick="btnOpenPop_Click" />
</div>
</form>
</body>
</html>
test.cs中相關
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOpenPop_Click(object sender, EventArgs e)
{
string url = "http://www.dotnetcurry.com";
ClientScript.RegisterStartupScript(this.GetType(), "OpenWin", "<script>openNewWin('" + url + "')</script>");
}
}
您是否嘗試過使用FireBug來檢查/調試代碼或錯誤控制檯以查看發生了什麼問題? – DaveDev
雅我檢查,控制達到javascript openNewWin函數,但我沒有看到任何錯誤 – mahesh
你確定你真的到達那條線嗎?打開控制檯並輸入:window.open('http:// www.dotnetcurry.com','MyWindow','width = 600,height = 600,toolbar = 1');那可行。再次嘗試在函數調用的最後添加一個分號?順便說一下,你的瀏覽器是什麼? –