如何在此代码中添加 5 秒的时间延迟?
<script type="text/javascript">
if (document.location.href.indexOf('url-wording') > -1) {
document.location.href = 'http://www.google.com/';
}
</script>
最佳答案
if(document.location.href.indexOf('url-wording') > -1) {
setTimeout(function() {
document.location.href = 'http://www.google.com/';
}, 5000); // 5000ms = 5s
}
关于javascript - 如何为 JS 重定向添加延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47675251/