提醒消息并重定向(或不重定向)

发布于 2024-11-11 07:55:03 字数 499 浏览 2 评论 0原文

假设我正在制作一个节日网站,如果您今天进入,您将看到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

醉城メ夜风 2024-11-18 07:55:03

最简单的方法是使用 window.confirm()。它类似于alert(),但它有2 个按钮:“确定”和“取消”。如果用户按下“确定”,则返回 true;如果用户按下“取消”,则返回 false。

<script>
    if (window.confirm('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>

但在页面加载时弹出确认窗口可能会让用户感到惊讶。您可以通过将消息放在页面上(带有指向 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.

<script>
    if (window.confirm('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 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).

神魇的王 2024-11-18 07:55:03

使用 window.confirm 而不是 window.alert

Use an window.confirm instead of the window.alert

倦话 2024-11-18 07:55:03

使用确认

  if (confirm('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';
    }

示例: http://jsfiddle.net/niklasvh/hERqw/

Use confirm.

  if (confirm('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';
    }

Example: http://jsfiddle.net/niklasvh/hERqw/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文