我有url重定向脚本或url引用脚本。
我想增加5秒等待,然后url重定向到所需的url。
<script>
var url_index = window.location.href.indexOf('url=');
if (url_index != -1)
{
url_go = window.location.href;
url_go = url_go.substring(url_index + 4);
//document.write(url_go);
window.location.href = url_go;
}
var $_ = function(x){if(!document.getElementById){return;} else{ return document.getElementById(x);}}
</script> 输出为http://transistortechnology.blogspot.comurl=http://imgur.com
当我打开上面的url然后它突然重定向,但我要加5秒等待。
在上面的脚本代码中是否有可能。
我将该脚本放在blogger头部分。
发布于 2020-05-29 05:36:14
<script>
var count = 15; // Number of seconds to wait
var counter; // Handle for the countdown event.
function start() {
counter = setInterval(timer, 1000);
}
function timer() {
// Show the number of remaining seconds on the web page.
var output = document.getElementById("displaySeconds");
output.innerHTML = count;
// Decrease the remaining number of seconds by one.
count--;
// Check if the counter has reached zero.
if (count < 0) { // If the counter has reached zero...
// Stop the counter.
clearInterval(counter);
// Start the download.
window.location.href = "URL to open";
//if you want to open in new window then use window.open(url);
return;
}
}
window.addEventListener("load", start, false);
</script>
<div>
Your download will begin in <span id="displaySeconds">15</span> seconds.<br />
</div>感谢技术专家为这个剧本。我在他的博客上找到了这个
https://stackoverflow.com/questions/14658971
复制相似问题