我在js中有此代码。它将我站点上的所有外部链接重定向到另一个等待页面,然后在10秒后返回主外部链接。问题是它直接进行重定向,而我不想要那样。我希望它单击按钮后将其重定向到外部链接。 这是一个示例:https://androidmood-1.blogspot.com/2019/02/stormfall-saga-of-survival-v1112-mod.html
这是带有JS代码的等待页面:
<script type="text/javascript">//<![CDATA[ //add Font Awesome var cb = function() { var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = '//maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css'; var h = document.getElementsByTagName('head')[0]; h.parentNode.insertBefore(l, h); }; var raf = requestAnimationFrame || mozRequestAnimationFrame || webkitRequestAnimationFrame || msRequestAnimationFrame; if (raf) raf(cb); else window.addEventListener('load', cb); //]]></script>
<script type="text/javascript">
var seconds;
var temp;
function removem1() {
var xkl = getQueryVariable("url");
var nkl=xkl.replace("&m=1", "");
document.getElementById("reload").innerHTML=nkl;
}
removem1();
document.getElementById('reload').href=window.location.href;
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("?&&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=_");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
function countdown() {
seconds = document.getElementById('countdown').innerHTML;
seconds = parseInt(seconds, 10);
if (seconds == 0) {
temp = document.getElementById('countdown');
parent.location.replace(document.getElementById("reload").innerHTML)
return;
}
seconds--;
temp = document.getElementById('countdown');
temp.innerHTML = seconds;
timeoutMyOswego = setTimeout(countdown, 3200);
}
setTimeout(function(){ countdown(); }, 1000);
</script>
</div>
<style type="text/css">
a#reload {display: none;}
#arabes1 {background: #ffa366;padding: 14px;font-size: 35px; font-Times: cursive;}
</style>
<div dir="rtl" style="text-align: right;" trbidi="on">
<div dir="ltr" style="text-align: center;" trbidi="on">
Please Wait For Few Seconds. . .
<div id="arabes1">You will be redirected to the link after <span id="countdown"> 10 </span> Seconds
<i class="fa fa-spinner fa-spin" style="font-size: 45px;"></i>
<a id="reload" href="#"></a></div>
</div>
答案 0 :(得分:0)
此行将您重定向到另一页。
parent.location.replace(document.getElementById("reload").innerHTML)
return;
将其删除,相反,您可以显示一个按钮,单击该按钮即可将您重定向。