open a new window when user leaves my site

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • millie
    First Lieutenant

    • Apr 2009
    • 170

    open a new window when user leaves my site

    Hello

    Not sure if this is the correct forum for this question. What I want to do is; open a new window (to say good-bye and please come again) when a visitor leaves my website (going to another site or closing the browser). I tried the onUnload event, javascript function, window.open ('http://subeagle.com'); properties of a page, but that did not work. Can someone point me to where I can read and learn how to do this properly?

    Thanks
    Millie
    www.subeagle.com
  • leescatnet
    Master Sergeant

    • Jul 2009
    • 63

    #2
    Re: open a new window when user leaves my site

    easy set the link to open in a new tab and they won't leave your site jsut set it to _blank or for more info see the tutorials here

    Video tutorials about how to create an amazing website with the BlueVoda website builder, brought to you by VodaHost web hosting.
    Sincerly Leescatnet

    Comment

    • wysiwyg4
      Major

      • Nov 2007
      • 477

      #3
      Re: open a new window when user leaves my site

      Hi Millie,

      I don't know if you have come up with the answer yet or not,

      The following code will go between the HEAD tags.

      <SCRIPT LANGUAGE="JavaScript">

      function popUp(URL) {
      day = new Date();
      id = day.getTime();
      eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,men ubar=1,resizable=1,width=400,height=500,left = 312,top = 134');");
      }
      </script>

      And the following will go on your page in HTML box

      <form>
      <input type=button value="You come back now, you hear" onClick="javascript:popUp('http://www.yoururl.com/message.html')">
      </form>

      P.S. If you look at the function, you have

      toolbar=1,scrollbars=1,location=1,statusbar=1,menu bar=1,resizable=1 and
      of course the size of the window.

      Anything you don't want, you put a 0 in place of 1.

      Try it and see if that's what you want. You have to make a thank you page with a message or whatever. I call it message.html
      Doable Personal Finance

      Comment

      • Watdaflip
        Major General

        • Sep 2005
        • 2116

        #4
        Re: open a new window when user leaves my site

        I don't know if you want a to load a different webpage, or just a small prompt they can hit just "Ok" and it closes.

        If its the latter, you can just insert this code inside your <body> tag

        Code:
        [FONT=monospace]
        [/FONT]onbeforeunload="alert('Goodbye, please come again!');"
        If you want an actual popup window replace the whole alert() funciton in he code above with somelike like the window.open() function in the post above mine.

        Do note, this is going to annoy the hell out of frequent visitors to your site. When people close out of your site they probably won't want to be bothered with another window that opens up (or a simple prompt for that matter). Just something to think about.

        Hope that helps

        Register/Login Script
        Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

        Comment

        • wysiwyg4
          Major

          • Nov 2007
          • 477

          #5
          Re: open a new window when user leaves my site

          The script above will only be executed when the visitor
          clicks on that button.
          Doable Personal Finance

          Comment

          • millie
            First Lieutenant

            • Apr 2009
            • 170

            #6
            Re: open a new window when user leaves my site

            All

            thanks for the guide. Unfortunately, I am still working on how to do what I want to do. Let me explain so that it's clear (I hope - I need to really get out of this bad sentence construction. I am sure it has a name that english professors always warn their students about.)

            This is what I want to do. I want to popup a small window with 'sorry to see you go and please come back soon' message. I want this popup window to appear when:

            1) the visitor leaves my website (the URL changes from my website to another, is there an event for this that can be monitored?)
            2) the visitor closes the browser (is this an onUnload?)

            These are the events I want to capture so I can then popup my "pleading" window.

            Please let me know if this is still confusing. Thanks for the assist.
            Millie
            www.subeagle.com

            Comment

            • Karen Mac
              General

              • Apr 2006
              • 8332

              #7
              Re: open a new window when user leaves my site

              You can do this with popunder or popover scripts however, you will annoy 99&#37; of people and they will NEVER come back. It might grab a few but it will chase off even more. Also.. if they use any kind of site monitoring tools .. this will get you on the bad list and might even get you blocked from future viewing.

              If you want scripts that do this, just google popups or pop unders.

              Karen

              VodaHost

              Your Website People!
              1-302-283-3777 North America / International
              02036089024 / United Kingdom
              291916438 / Australia

              ------------------------

              Top 3 Best Sellers

              Web Hosting - Unlimited disk space & bandwidth.

              Reseller Hosting - Start your own web hosting business.

              Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)


              Comment

              • wysiwyg4
                Major

                • Nov 2007
                • 477

                #8
                Re: open a new window when user leaves my site

                I agree with Karen 100%.

                I always try to make it simple not for myself
                but entirely for the visitor.

                Sooner or later - in most cases it would be sooner - visitors are gonna
                leave your website because it is their choice not the webmasters.

                What the website builder can do, ideally, is to have the best and fresh
                content on the subject of your website, make it easier for them
                to navigate not with some fancy and flashy things but solid, to the point,
                and concise presentation of the material.

                If the visitor stays on your site for a couple of minutes or more,
                you have done your job.

                Try to give the visitor good contents and in turn you would get a
                little closer to the search engines as well.

                Bells and whistles are fine if they make some good business sense.
                Otherwise the visitor gets annoyed. Think of the visitors as annoyed to
                begin with. Your job as webmaster is to remove their annoyance and
                attract their attention.

                Having said that, you can still do what Karen said.
                Doable Personal Finance

                Comment

                • millie
                  First Lieutenant

                  • Apr 2009
                  • 170

                  #9
                  Re: open a new window when user leaves my site

                  All

                  thank you for the assist. I have done what I wanted to do due mainly to your help. Much appreciated. After re-publishing with the flash feature, and trying it out myself, I then decided to follow your business web-sense and removed the annoying feature. 2 lessons for today, that is more than i usually get in a week.

                  Thank you wysiwg4, watdaflip, and karen
                  Millie
                  www.subeagle.com

                  Comment

                  Working...
                  X