在弹出窗口中单击按钮后重定向到页面

时间:2022-11-19 21:33:43

I have a link in my web page:

我的网页上有一个链接:

 <a class="dropdown-item" href="#" onclick="ChangePasswordPopup();">Change your password</a>

When this link is clicked, the popup opens defined below:

单击此链接时,将打开以下定义的弹出窗口:

function ChangePasswordPopup()
{
    var html=""; // to store the html content

    // Build the content of the change password popup form
    html+="<div class='col-md-12 divChangePasswordPopup' id='divChangePasswordPopup'>";
    html+="<div class='divBackground' id='divBackground' onclick='ClosePopup();'></div>";
    html+="<div class='panel panel-primary divForeground' id='divForeground'>";
    html+="<div class='panel-heading'>";
    html+="Change your password";
    html+="<a href='#' onclick='ClosePopup();' id='CloseButtonLink' title='close'>";
    html+="<span class='glyphicon glyphicon-remove' style='float: right; font-size: 18px; padding: 3px 3px 0px 0px;'></span>";
    html+="</a>";
    html+="</div>";
    html+="<div class='panel-body'>";
    html+="<form name='frmChangePassword' onsubmit='ChangePassword(this);'>";   .....form textboxes goes here.....
    html+="<button type='submit' name='btnSave' class='btn btn-primary-outline'";
    html+="style='position: relative; float:right;'>Save Changes <i class='glyphicon glyphicon-chevron-right'></i></button>";
    html+="<br/></div></li></form></div></div></div>";

    $("#divChangePasswordPopup").html(html);    
    disablescroll(); // disable the scrollbar for the webpage    
    return(false); // to prevent the calling form from executing    
}

This is working. When I try clicking the save button, I simply want to redirect to another page, so I did this:

这很有效。当我尝试单击“保存”按钮时,我只想重定向到另一个页面,所以我这样做了:

function ChangePassword(frm)
{
    window.location="login.php";
    return(false); // to prevent the calling form from executing

}

But it's not working. If I use that same window.location in a normal button on the web page it's working. But when using it in the popup, it's not working. Anyone knows how I can click a button on the popup form and redirect to the login page?

但它不起作用。如果我在网页上的普通按钮中使用相同的window.location它正在工作。但是当在弹出窗口中使用它时,它不起作用。任何人都知道如何点击弹出窗体上的按钮并重定向到登录页面?

the problem in jsfiddle code

jsfiddle代码中的问题

1 个解决方案

#1


0  

Try :

function ChangePassword()
{
    window.location.href = 'login.php';
    return false;
}

#1


0  

Try :

function ChangePassword()
{
    window.location.href = 'login.php';
    return false;
}