[英]Loading webpage after some time ASP.net using Javascript
它似乎是重复的,但是花费了很多时间仍然引起一些问题。 请有人指出我在做什么错。
我有一个按钮 ,当我单击它时,将调用JS函数 show()
<input type="button" onclick="show()" value="Add to Cart">
javascript代码如下
function show() {
document.getElementById("loadingDiv").style.display = "block";
setTimeout('Redirect()', 2000);
function Redirect() {
location.href = 'Index.aspx';
}
}
div设置为正确阻止 ,但是页面从不重定向 。 不知道是什么问题。
尝试这个。
function show() {
document.getElementById("loadingDiv").style.display = "block";
setTimeout(function(){
location.href = 'Index.aspx';
}, 2000);
}
或在show
函数主体外创建redirect
函数,并使用名称(而不是字符串)来调用它。
更改此行setTimeout('Redirect()', 2000);
设置为setTimeout(Redirect(), 2000);
基本上在setTimeout参数中,函数名称不应用引号引起来
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.