Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    open pop-up window on browser close

    Hi!

    I need to open a window when:
    1 user leaves the site
    2 when the browser is closed.
    I tried the 'unLoad' event but it works only for the user leaves site case and not the browser close. Here is the code I tried:
    <html>
    <head>
    <title>Detecting browser close </title>
    <script type="text/javascript">
    function doUnload()
    {
    myWin= open("exit_site.php", "exitWin", "width=50,height=50");
    }
    </script>
    </head>

    <body onunload="doUnload()"
    <h4>Close browser!</h4>
    </body>
    </html>

    Neep your help, please

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Quote Originally Posted by vitvor
    I need to open a window when:
    1 user leaves the site
    1. I should be able to leave a site without having a pop up...
    Quote Originally Posted by vitvor
    2 when the browser is closed.
    2. I should be able to close my browswer without a pop up...

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vitvor
    I need to open a window when:
    1 user leaves the site
    2 when the browser is closed.
    you don't need anything. but your site's users do and it is called satisfied user-experience or customer satisfaction, neither of which will be available to them if you throw popups in their faces.

    tf for popup blockers.
    *keep it simple (TM)

  • #4
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, that's not much of a help.

    But if it realy makes you feal better, it's supposed to be a self closing pop-up

  • #5
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Most people have pop up blockers installed, and it is now part of IE with SP2 . Therefore no one will be able to see it in the first place unless they add your site to their safe list.

    You should try looking for another alternative to this.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #6
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vitvor
    But if it realy makes you feal better, it's supposed to be a self closing pop-up
    is that after it has installed the adware onto our machines?
    *keep it simple (TM)

  • #7
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Listen, it's absolutely harmless thing. I need it as a part of my academic project. However the adware can be installed not only via pop-up. Did you know? Anyway, I see that you don't want to help. So I won't waste my time on that argument.
    Thanks anyway

  • #8
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vitvor
    Listen, it's absolutely harmless thing.
    we've only got your word on that.


    Quote Originally Posted by vitvor
    I need it as a part of my academic project.
    oh, it's a school project. I see


    Quote Originally Posted by vitvor
    However the adware can be installed not only via pop-up. Did you know?
    yes, we do. just ask The Register!


    Quote Originally Posted by vitvor
    Anyway, I see that you don't want to help. So I won't waste my time on that argument.
    it's not that I (or anyone else, perhaps) doesn't want to help. but i'm skeptical of your intent. this is all the stronger now since you've evaded saying why you need onclose popups - is that why you've questioned my motivations?
    *keep it simple (TM)

  • #9
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry

    Grow up, people.

    He wants to know how to code it, and if you've got a popup blocker installed, why should you really care?

    Here's some code I know of.

    On your page, set a global variable,
    var cleanexit = false;

    on every link and form out from your page, onclick="cleanexit=true;" or onsubmit="cleanexit=true;"

    on your onUnload="if (!cleanexit) window.open('url','windowname','scrollbars=#,status=#,resizable=#,height=#,width=#')">

    The reason you put all the onclicks and onsubmits is so that your page doesn't pop-up during standard navigation, but only when someone leaves your site or closes the window.

    Can anyone else suggest a better solution without being a big whiny anti-popup baby?

  • #10
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Squashua,

    That was awesome! This forum is designed to help fellow programmers with question, people are soooooo sensative on this site. It is actually pretty funny.

    I guess you shut them up with your comment too, props to you for speaking up!


  • #11
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by PROWEBWORKS.NET
    I guess you shut them up with your comment too, props to you for speaking up!
    Hardly. Helping someone create the code to do this sort of thing, is the same as encouraging it. Intelligent developers have realised that scripts like this help no-one, and see no point in helping someone create it.

  • #12
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    please can thou write full code, i cant understand how can i do it

  • #13
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Guilty until proven innocent, it seems.

    Gotta say, I'm with squashua on this one.

    We don't know that s/he's doing anything that users can't prevent; certainly nothing criminal. (Even if we did know that it was to be put to an annoying use, if they want to alienate their visitors, so be it. All the more eyeballs for the rest of us.)

    Tell them how to do it, then tell them why they shouldn't do it. Keeping members ignorant is not the best way to win trust and respect for your views.
    At least give people the benefit of the doubt.

    There's enough thought-policing going on as it is on web dev forums without making this yet another place where a person can't simply get a straight answer because of a resident brigade of well-meaning 'net nannies'.

    Imho, when a knowledgable member will only pass on technical help on the condition that the end use meets their approval, they should simply stick to not posting in cases such as this.

    There's nothing "intelligent" about being obstructive.
    Attempting to claim intellectual superiority with statements about what you think "Intelligent developers" will or won't do is, frankly, childish.


    [edit]

    Just noticed the post dates.
    Still, probably needed saying anyway.
    Last edited by Bill Posters; 07-02-2006 at 01:26 PM.

  • #14
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Some of us are watching... :-)

  • #15
    New to the CF scene
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow open pop-up window on browser close

    Hi,
    I would recommend the following code to achieve this task:
    <SCRIPT LANGUAGE=JavaScript TYPE=text/javascript>
    var Path = 1;
    function OpenWindow(url)
    { if(Path == 1){
    OpenWin=window.open(url,"PopUp","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,wi dth=1150,height=780");
    OpenWin.blur();
    window.focus();
    }
    }
    </SCRIPT>

    And in the body tag:
    <body onunload="OpenWindow('The url you need to pop up')">

    Also define:
    Path = 0; //where you do the form submission

    Hope this will help!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •