...

View Full Version : Javascript Confirm Message Dialog



suzair
01-21-2012, 05:50 AM
http://tinyurl.com/bw2y3sr
This is my site and I want to create a Yes and No dialogue box when user closes a browser so this popup confirm dialogue should appear. Can anyone help me?

felgall
01-21-2012, 05:53 AM
Do a search for "lightbox script". You can then create your form containing whatever you want it to say using that script.

suzair
01-21-2012, 06:01 AM
I am sorry I do not want a lightbox I want a default like confirm message
popup with yes or no buttons

Philip M
01-21-2012, 08:49 AM
Is this what you mean?



<script type = "text/javascript">

window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave this page?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}

</script>

Quizmaster: In which book is Room 101 a place to be feared?
Contestant: 101 Dalmations

suzair
01-21-2012, 02:27 PM
Yes this is fine but the main issue is I just want to show this same popup on just homepage not on the other pages . Like if some one is on "About Us " page and then closes browser then this popup should not appear, it just needs to display only on homepage is it possible?

Philip M
01-21-2012, 02:29 PM
Yes this is fine but the main issue is I just want to show this same popup on just homepage not on the other pages . Like if some one is on "About Us " page and then closes browser then this popup should not appear, it just needs to display only on homepage is it possible?

Well, yes. Just include the script on the pages where you want it.

Before you ask, it is not possible to distinguish leaving the page (perhaps for another page) and closing the browser.

suzair
01-21-2012, 02:32 PM
Thank you for your quick reply
Regards

felgall
01-21-2012, 10:47 PM
It is also not possible to distinguish reloading the current page so any page you include that on will also display if the person decides to reload the page.

Also all the built in dialogs are intended for debugging only and have additional options in some browsers (such as being able to disable all future dialogs or disable JavaScript completely for the site).

suzair
01-23-2012, 05:41 AM
Thank you for your quick reply



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum