在按钮上单击弹出窗口并打开一个新的选项卡窗口并在javascript中关注它

时间:2013-09-20 18:08:10

标签: c# javascript asp.net

我的页面中有asp菜单项按钮。所以当我点击该按钮时,我需要在当前选项卡上打开一个弹出窗口并打开一个新选项卡并专注于它。当用户回到实际标签时,会在弹出之前单击“确定”,然后再继续操作。这是我到目前为止所做的:

var menuTable = document.getElementById("<%=ASPTableMenu.ClientID%>");
var menuLinks = menuTable.getElementsByTagName("a");
menuLinks[0].onclick = function () {  
    var winPopup = window.open("z_container.aspx"); 
    if (winPopup) { 
        winPopup.focus();
    } 
    alert('test'); 
}

而不是警告我需要打开一个弹出的OK按钮,当用户点击确定我需要运行一些条件。

由于

1 个答案:

答案 0 :(得分:0)

您必须使用confirm:

,而不是提醒
var menuTable = document.getElementById("<%=ASPTableMenu.ClientID%>");
var menuLinks = menuTable.getElementsByTagName("a");
menuLinks[0].onclick = function () {  
    var winPopup = window.open("z_container.aspx"); 
    if (winPopup) { 
        winPopup.focus();
    } 
    //alert('test'); 
    if (confirm("Your message here")) {
        //OK button clicked; add your code here
    }
}