具有重定向功能的Windows警报javascript
这是我的脚本具有重定向功能的Windows警报javascript,javascript,php,jquery,Javascript,Php,Jquery,这是我的脚本 <script> function myAlert() { alert("You have changed your username, you will be logged out in order changes to be applied"); } </script> 函数myAlert(){ 警报(“您已更改用户名,您将注销以应用更改”); } 这是我的按钮 <input type="submit" value="Save" na
<script>
function myAlert() {
alert("You have changed your username, you will be logged out in order changes to be applied");
}
</script>
函数myAlert(){
警报(“您已更改用户名,您将注销以应用更改”);
}
这是我的按钮
<input type="submit" value="Save" name="btnPass" class="button" onclick="myAlert()";/>
我想知道,当警报中的“OK”按钮按下时,是否有办法添加重定向脚本。如何将其添加到脚本中?如何将其添加到脚本中?谢谢 使用而不是警报
confirm()方法显示一个模式对话框,其中包含一条可选消息和两个按钮OK和Cancel
@Tushar使用确认对话框是正确的。下面是他的答案的修改版本,肯定有用
function myAlert() {
var confirmed = confirm("You have changed your username, you will be logged out in order changes to be applied");
// If OK button is clicked
if (confirmed == true) {
window.open("path-to-logout script","_self");
}
}
出于某种原因,这个脚本不起作用,我不知道为什么。它只是在我所在的当前页面上重定向,一旦我单击“确定”按钮,它就会在同一页面上重新加载。我尝试了@tushar it,只是它无法处理我的代码,我甚至不知道为什么:(
function myAlert() {
var confirmed = confirm("You have changed your username, you will be logged out in order changes to be applied");
// If OK button is clicked
if (confirmed == true) {
window.open("path-to-logout script","_self");
}
}