1

好的,我有这个脚本,它打开所需的页面,然后在所需的时间关闭。关闭时如何让它重定向到某个东西而不是 google.com

    <!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Test Page</title>
<style>
body {
font-family: sans-serif;
}
</style>
</head>
<body>
<p><a href="#" id="target">Start Earning Points</a>; You will will <b>1</b> point per <b>1</b> view.</p>
<script>
(function() {
document.getElementById("target").onclick = function() {
var wnd = window.open("http://google.com");
setTimeout(function() {
wnd.close();
}, 15000);
return false;
};
})();
</script>
<script src="/js/render/edit.js"></script>
<script>var _gaq=[['_setAccount','UA-1656750-13'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)})(document,'script')</script></body>
</html>
4

2 回答 2

1

试试这个,现在窗口不会关闭,它会重定向到 yahoo.com。希望这就是你正在寻找的。

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Test Page</title>
<style>
body {
font-family: sans-serif;
}
</style>
</head>
<body>
<p><a href="#" id="target">Start Earning Points</a>; You will will <b>1</b> point per <b>1</b> view.</p>
<script>
(function() {
document.getElementById("target").onclick = function() {
var wnd = window.open("http://google.com");
setTimeout(function() {
wnd.location.href = "http://yahoo.com";
//wnd.close();
}, 15000);
return false;
};
})();
</script>
<script src="/js/render/edit.js"></script>
<script>var _gaq=[['_setAccount','UA-1656750-13'],['_trackPageview']];(function(d,t)
{var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)})(document,'script')</script>
</body>    
</html>
于 2012-07-13T05:44:36.613 回答
0

其实我不清楚你在问什么。如果您要求在特定时间后重定向,则应按以下方式修改脚本:

   <script>
      (function() {
        document.getElementById("target").onclick = function() {
        var wnd = window.open("http://google.com");
        setTimeout(function() {
        wnd.location = 'http://yahoo.com';
       }, 1500);
       return false;
     };
    })();
   </script>

谢谢

于 2012-07-13T05:46:43.803 回答