2

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!

4

3 に答える 3

8

最も簡単な方法は、を使用することwindow.confirm()です。alert()に似ていますが、[OK]と[キャンセル]の2つのボタンがあります。ユーザーが[OK]を押した場合は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を使用している可能性があります)を使用することで、より微妙なものにすることができます。

于 2011-05-30T15:28:14.380 に答える
6

window.confirmwindow.alertの代わりに使用します

于 2011-05-30T15:24:48.243 に答える
5

を使用し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';
    }

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

于 2011-05-30T15:26:02.287 に答える