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

Redirecting to a page after clicking button in a popup

本文关键字:重定向 按钮 窗口 单击      更新时间:2023-09-26

>我的网页上有一个链接:

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

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

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    
}

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

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

但它不起作用。如果我在网页上的普通按钮中使用相同的窗口位置,它就可以工作。但是在弹出窗口中使用它时,它不起作用。有人知道我如何单击弹出表单上的按钮并重定向到登录页面吗?

JSFIDDLE 代码中的问题

尝试:

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