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='';
</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!
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!
Share Improve this question asked May 30, 2011 at 15:22 Toni Michel CaubetToni Michel Caubet 20.2k58 gold badges217 silver badges387 bronze badges3 Answers
Reset to default 8The 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).
Use an window.confirm
instead of the window.alert
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/