by sdzh
3 replies
  • WEB DESIGN
  • |
Hi
I'll take my intimidatingly large first step here with a question regarding exit pop ups that are commonly found on squeeze pages.
You know the type - just as you click on the red cross to leave the site, a pop up appears and offers you a better offer if you opt to stay on the page.

I've spent a while searching where to get hold of the code to do this, but have drawn a blank so far.

Could anyone please advise a site / service where I can get something like this?

All help gratefully accepted
Thanks

#exit #pop #ups
  • Profile picture of the author mikeonrails
    Use a javascript event handler called "onunload" to do it very easily. Another option is onbeforeunload, but not all browsers support it.

    <BODY onUnload="alert('This is a popup')">

    Be aware that people have a love-hate relationship with exit popups: some will look at the upsell and others will never visit your site again because of it..
    {{ DiscussionBoard.errors[2298180].message }}
    • Profile picture of the author sdzh
      Originally Posted by mikeonrails View Post

      Use a javascript event handler called "onunload" to do it very easily. Another option is onbeforeunload, but not all browsers support it.

      <BODY onUnload="alert('This is a popup')">

      Be aware that people have a love-hate relationship with exit popups: some will look at the upsell and others will never visit your site again because of it..
      Thanks Mike.
      I have no experience with this type of coding. Is it a simple matter of me your text above into the page where I want the pop-up to appear?

      On a Google search for "onUnload", I found the following code. Is that what needs to be used?

      <script language="javascript">
      var unloadPop = true;
      function Nav() {
      unloadPop = false;
      window.navigate(arguments[0]);
      }
      function UnloadTrigger() {
      if (unloadPop) {
      alert("This is where I'd pop a window.");
      }
      }
      window.onunload = UnloadTrigger;
      </script>

      Sorry to be such a noobie
      :p
      {{ DiscussionBoard.errors[2299223].message }}
      • Profile picture of the author mikeonrails
        There are tow different ways to do it. The way I listed is the inline way, so you put onUnload directly into the tag. So

        <html>
        <head>
        </head>
        <body onUnload="onUnloadEventHandler">
        </body>
        </html>

        The other way is your way, where you have

        window.onunload = UnloadTrigger;
        somewhere in a script tag or in an attached script. Either is fine.
        {{ DiscussionBoard.errors[2301760].message }}

Trending Topics