提醒消息并重定向(或不重定向)
假设我正在制作一个节日网站,如果您今天进入,您将看到 2010 版,因为 2011 版尚未完成,
我想让我的用户知道他们正在访问旧网站,并且他们将重定向到 Facebook 页面(直到新网站完成),
使用此代码我将重定向到我们的 Facebook 页面
<SCRIPT LANGUAGE='JavaScript'>
window.alert('This is the old edition of our webiste. The new one will be avaliable soon. You would be redirected')
window.location.href='http://facebook.com/ourfacebookpage';
</SCRIPT>
但是我该怎么做才能允许用户留下来? (例如,取消/留在此处按钮)以便用户可以看到旧网站(但他知道这是旧网站)
非常感谢您的任何想法!
lets say i'm making a festival website, and if you enter today you will se the 2010 edition because the 2011 edition it's not finished,
And i want to let to my users know that they are seing the old website and that they will be redirected to the facebook page (untill the new website its finished),
with this code i would be redirecting to our facebook page
<SCRIPT LANGUAGE='JavaScript'>
window.alert('This is the old edition of our webiste. The new one will be avaliable soon. You would be redirected')
window.location.href='http://facebook.com/ourfacebookpage';
</SCRIPT>
But how could i do to allow user staying? (example, cancel / stay here button) so user can see the old website (but he knows it's the old website)
thanks a lot for any idea!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的方法是使用
window.confirm()
。它类似于alert(),但它有2 个按钮:“确定”和“取消”。如果用户按下“确定”,则返回 true;如果用户按下“取消”,则返回 false。但在页面加载时弹出确认窗口可能会让用户感到惊讶。您可以通过将消息放在页面上(带有指向 Facebook 页面的链接)而不是弹出警报/确认框,并使用另一个链接从页面中删除该消息(可能使用 JavaScript)来使这一点变得更加微妙。
The simplest way is to use
window.confirm()
. It's like alert() but it has 2 buttons: OK and Cancel. It returns true if the user pressed OK and returns false if the user pressed Cancel.But having a confirm window popup on page load may surprise users. You can make that more subtle by putting the message on your page (with link to your facebook page) instead of popping up the alert/confirm box, and have another link that removes that message from the page (maybe using JavaScript).
使用
window.confirm
而不是 window.alertUse an
window.confirm
instead of the window.alert使用
确认
。示例: http://jsfiddle.net/niklasvh/hERqw/
Use
confirm
.Example: http://jsfiddle.net/niklasvh/hERqw/