Google Answers Logo
View Question
 
Q: JS Script - Pop on exit except when clicking on buy button ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: JS Script - Pop on exit except when clicking on buy button
Category: Computers > Internet
Asked by: cclegg06-ga
List Price: $10.00
Posted: 06 Oct 2003 05:10 PDT
Expires: 05 Nov 2003 04:10 PST
Question ID: 263045
I’m trying to write a script that will pop a window of specified
dimensions and location on the screen when someone exits a page in any
way other than clicking on a paypal purchase button.

So far, I’ve been playing with:

<script language="javascript">
var noBuy_exit = 1;
var page = "../mr/csNoBuy.htm";
var windowprops = "width=360,height=150,location=no,toolbar=no,menubar=no,resizable=no,left=10,top=10";
function noBuy() {
   if (noBuy_exit == 1) {
      window.open(page, "", windowprops)}
   }
    </script>

I’m trying to pop on
http://www.lumenresearch.com/serve/rpts/csRpt.htm.

Can you provide the JavaScript?

Thanks.
Answer  
Subject: Re: JS Script - Pop on exit except when clicking on buy button
Answered By: joseleon-ga on 06 Oct 2003 07:13 PDT
Rated:5 out of 5 stars
 
Hello, cclegg06:

   I have done what you want in a separate files to check if this is
exactly the behaviour you want, once you agree, I will integrate the
javascript it on your page.
   
These are the contents of the index.htm:
   
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
var buttonClicked=false;
  
function MM_openBrWindow(theURL,winName,features) { //v2.0
  if (!buttonClicked) window.open(theURL,winName,features);
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
//-->
</script>
</head>

<body onUnload="MM_openBrWindow('popup.htm','','width=360,height=150')">
<!-- START PAYPAL BUTTON -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="admin@lumenresearch.com">
<input type="hidden" name="item_name" value="2Q03 - Customer Service
Benchmarks">
<input type="hidden" name="item_number" value="2Q03CS">
<input type="hidden" name="amount" value="195.00">
<input type="hidden" name="image_url"
value="http://www.lumenresearch.com/images/cc/ppLumen_150x50.JPG">
<input type="hidden" name="return"
value="http://www.lumenresearch.com/serve/rpts/csDel.htm">
<input type="hidden" name="cancel_return"
value="http://www.lumenresearch.com/about/contact.htm">
<input type="hidden" name="cn" value="Comments:">

<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
  <input name="submit" type="image"
onClick="MM_callJS('buttonClicked=true')"
src="https://www.paypal.com/images/x-click-butcc.gif" alt="Make
payments with PayPal - it's fast, free and secure!" width="73"
height="44" border="0">
</form>
<!-- END PAYPAL BUTTON -->       
</body>
</html>

And these are the contents of the popup.htm page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body>
This is the popup 
</body>
</html>

Instead copy and paste, and to prevent the word wrapping, you can
download the full sources from here:

http://www.xpde.com/close.zip

To test it, simply open in your browser the index.htm file, it will
show a paypal button, if you close the browser window, the popup will
be shown, but if you click on the paypal button, you just will be
redirected to the paypal page and no popup will be shown. As I said
before, this is an open answer, and if you agree with everything, I
will integrate it into your original page. In any case, don't hesitate
to requeste for a clarification, I'm here to help you.

Regards.

Request for Answer Clarification by cclegg06-ga on 06 Oct 2003 07:43 PDT
Yes, that's the idea to a "T".

Thanks.

Clarification of Answer by joseleon-ga on 06 Oct 2003 07:46 PDT
Hello, cclegg06:

  In that case, I'm going to download your page, adapt it to work this
way, and then, post it to you.

Regards.

Request for Answer Clarification by cclegg06-ga on 06 Oct 2003 07:46 PDT
Thanks.

Clarification of Answer by joseleon-ga on 06 Oct 2003 08:12 PDT
Hello, cclegg06:

 You can download the patched version from here:

http://www.xpde.com/csRpt.zip

Before update the page on your server, please, make a backup copy of
your original one. Also, if you need help customizing the popup window
or you have any problem, please, don't hesitate to request for a
clarification.

Regards.

Request for Answer Clarification by cclegg06-ga on 06 Oct 2003 08:44 PDT
ThanksThanks.

After integrating the function, I realize that it would be nice if I
could control how often it popped any given visitor.  I thought I
could easily integrate it with a current cookie script I use but I
can’t figure it out.

If you could lend me your mind once again I’ll provide a $10.00 tip. 
If not, no problem, I’ll close out the question and open a new one.

I moved your script to a file that has the cookie script I’m playing
with below the current functioning script.  Please make any changes to
a copy of the JS file itself.

The files at:  http://www.lumenresearch.com/js/csNoBuy.js

Thanks again.

Clarification of Answer by joseleon-ga on 06 Oct 2003 11:38 PDT
Hello, cclegg06:
  Sure I follow this answer, no problem ;-)

Regarding control the popups, what do you want exactly? That is, do
you want to popup depending on the times the user visits your page,
depending on a expiration date on the cookie, please, tell me what do
you want and you have it.

Regards.

Request for Answer Clarification by cclegg06-ga on 06 Oct 2003 12:28 PDT
I'd like to control how often the page pops.  For example, once a
week.  As the cookie is designed now, it expires after 1 day.  The
idea being I don't want to keep annoying someone with the pop if they
are considering a purchase.

One pop per person per week is my goal.

Clarification of Answer by joseleon-ga on 07 Oct 2003 01:33 PDT
Hello, cclegg06:

  I have updated your js file to check if there is a cookie on the
client's browser and if not, set the cookie and popup the window, you
can download it from here:

http://www.xpde.com/csNoBuy.js

At the top of the code you can set how many days will be the cookie
enabled, I have reused your code instead add new one. Feel free to
request for any clarification or new features. I have tested it with
IE and Mozilla/Firebird, in any case, if you find any problem, please,
don't hesitate to request a clarification.

Regards.

Request for Answer Clarification by cclegg06-ga on 07 Oct 2003 04:45 PDT
I'm testing it at: http://www.lumenresearch.com/serve/rpts/csRptt.htm
with no success.  I'm not getting any error messages, just no pop.

Is it possilble that the cookie is interfearing with the cookie laid
down on the home page (www.lumenresearch.com).  This original code is
used to prevent more than one pop on the homepage.

Thanks,

Chris

Request for Answer Clarification by cclegg06-ga on 07 Oct 2003 04:48 PDT
Ignore my last comment.  It is a cookie issue and that isn't such a
bad thing.  I like the idea of limiting one pop per visitor regardless
of which pop it is.  Thanks again.  I'll close things out.

Clarification of Answer by joseleon-ga on 07 Oct 2003 05:35 PDT
Hello, cclegg06:
  Nice everything worked, and thanks for the tip and such a great
comment, hope to see you again using Google Answers!! ;-)

Regards.
cclegg06-ga rated this answer:5 out of 5 stars and gave an additional tip of: $15.00
Stuck with me until the problem was resolved.  Great person to work with.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy