gpt4 book ai didi

javascript - 如何在 JavaScript 中按下自定义警报框的“确定”按钮时重定向页面

转载 作者:行者123 更新时间:2023-12-02 16:37:19 25 4
gpt4 key购买 nike

这是我的 JavaScript 代码

<script type="text/javascript">
Alert.render('Saved!','myurl.php');
</script>

渲染函数是

function CustomAlert() {
this.render = function (dialog,url) {
var winW = window.innerWidth;
var winH = window.innerHeight;
var dialogoverlay = document.getElementById('dialogoverlay');
var dialogbox = document.getElementById('dialogbox');
dialogoverlay.style.display = "block";
dialogoverlay.style.height = winH + "px";
dialogbox.style.left = (winW / 2) - (550 * 0.5) + "px";
dialogbox.style.top = "100px";
dialogbox.style.display = "block";
document.getElementById('dialogboxhead').innerHTML = "Heading";
document.getElementById('dialogboxbody').innerHTML = dialog;
document.getElementById('dialogboxfoot').innerHTML = "<button class='btn btn-info' onclick='Alert.ok(\"" + url + "\")'>OK</button>";
}
this.ok = function (url) {
window.location.href(url);
document.getElementById('dialogbox').style.display = "none";
document.getElementById('dialogoverlay').style.display = "none";
}
}
var Alert = new CustomAlert();

我的问题是单击“确定”按钮后页面没有重定向。请帮助我??

最佳答案

window.location.href 不是函数

window.location.href(url); 更改为 window.location.href = url;

关于javascript - 如何在 JavaScript 中按下自定义警报框的“确定”按钮时重定向页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27813528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com