下面的演示“着陆页”完全是OP要求的。当用户点击链接时,URL首先被保存到cookie中。用户被要求确认这个动作。当用户将来访问该页面时,它们将被自动重定向到他们先前的选择。
根据我的经验,用户更喜欢书签页,而不是以这种方式重定向。然而,决定OP的要求或对他/她的公司最适合的方式并不是我的决定。
<html>
<head>
<script type="text/javascript">
var redirect = (function() {
var DEBUG = false, // true to disable redirects
NAME = 'redirect=',
DAYS = 7, // number of days to redirect
cookie = document.cookie,
expires;
// read cookie and redirect
if (cookie.indexOf(NAME) >= 0) {
cookie = cookie.split(NAME).pop().split(';').shift();
cookie = decodeURIComponent(cookie);
if (DEBUG) alert('Redirect\n' + cookie); else location.href = cookie;
}
// set redirect
return function(url) {
if (confirm('Go to this link automatically on your next visit?')) {
expires = new Date();
expires.setDate(expires.getDate() + DAYS);
cookie = 'redirect=' + encodeURIComponent(url) + ';expires=' + expires.toUTCString() + ';path=/';
document.cookie = cookie;
}
if (!DEBUG) location.href = url;
}
})()
</script>
</head>
<body>
<img src="http://technical.walkerdendle.co.uk/_resx/images/logo.png">
<br>
<a href="javascript:void(0)" onclick="redirect('http://technical.walkerdendle.co.uk')">Technical</a>
<br>
<a href="javascript:void(0)" onclick="redirect('http://financial.walkerdendle.co.uk')">Financial</a>
</body>
</html>
听起来像一个计划!你有没有试图做到这一点? – dgig
如果用户希望在未来某个日期返回到目标网页,该怎么办? – Roberto
你能澄清你的问题吗?这很难回答一个声明;-) – Philipp