Alert box [ok] and [cancel] buttons

I have the following code to display an alert box if/when
the user leaves the current window:

--------------------------------------------------------------------
<head>

<script type='text/javascript'>
<!--
var NoExitPage = false;
function ExitPage() {
if(NoExitPage == false)      {
NoExitPage=true;
location.href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SSPZQ8R2T7238';

return"***************** WAIT! - HUGE DISCOUNT! *****************\n\n"+
"If you wanted the complete reseller package to *9* turnkey\n"+
"products worth $997, but the price of $27 was just a bit out\n"+
"of reach for you, then I can offer you the exact same offer\n"+
"you just passed up, but with a huge discount ...\n\n"+
"You will receive the exact same reseller package to *9*\n"+
"turnkey products worth $997 for the lowest introductory\n"+
"cost of only $17!\n\n"+
"Click the \[OK\] button for Instant Download Access!";
}
}
// -->
</script>

</head>

<body onBeforeUnload="return ExitPage();">
--------------------------------------------------------------------

Since most browsers display an [OK] and [Cancel] button
inside alert boxes, BUT Google Chrome displays [Leave this
Page] and [Stay on the Page] instead, can an expert kindly
modify the javascript to allow for either circumstance?

So, if the user is using Firefox or IE, then show as:

"Click the \[OK\] button for Instant Download Access!";

But if the user is using Google Chrome, then show as:

"Click the \[Leave this Page\] button for Instant Download Access!";
cbradstreetAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Adoryc666Commented:
You can test this.
	if (navigator.userAgent.match('Chrome')) {
		alert ("Click the \[Leave this Page\] button for Instant Download Access!");
	} else {
		alert ("Click the \[OK\] button for Instant Download Access!");
	}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rkeith2412Commented:
try this


<script type='text/javascript'> 
<!--
var NoExitPage = false;
function ExitPage() {
if(NoExitPage == false)      {
NoExitPage=true;
var btnText = "\[OK\]";
location.href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SSPZQ8R2T7238';
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if (is_chrome){ btnText = "\[Leave this Page\]"; }
return"***************** WAIT! - HUGE DISCOUNT! *****************\n\n"+
"If you wanted the complete reseller package to *9* turnkey\n"+
"products worth $997, but the price of $27 was just a bit out\n"+
"of reach for you, then I can offer you the exact same offer\n"+
"you just passed up, but with a huge discount ...\n\n"+
"You will receive the exact same reseller package to *9*\n"+
"turnkey products worth $997 for the lowest introductory\n"+
"cost of only $17!\n\n"+
"Click the "+btnText+" button for Instant Download Access!";
}
}
// -->
</script>

Open in new window

0
rkeith2412Commented:
Did my solution not work?  It seemed to work fine for me.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

MMDeveloperCommented:
I think the better solution would be to use the confirm() functionality

ret = confirm("blah blah blah");
if (ret) {
      //user clicked positively
}
else {
      //user clicked negatively.
}
0
cbradstreetAuthor Commented:
rkeith2412, your solution works really well for Chrome and IE browsers, but if I test on Firefox, the alert box comes up which is good, but before I have a chance to click OK or Cancel, I am directed to https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SSPZQ8R2T7238

Any ideas?
0
rkeith2412Commented:
I think this would best be addressed by using MMDeveloper's confirm idea. Then you only change the URL is they click ok.
0
cbradstreetAuthor Commented:
Would you mind modifying your script to include the

ret = confirm("blah blah blah");
if (ret) {
      //user clicked positively
}
else {
      //user clicked negatively.
}

This is a little over my head :-)

Many thanks!!!!

Chantelle :-))
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.