popup if user wants to close window or enter another url

Discussion in 'Javascript' started by libsfan01, Aug 5, 2006.

  1. libsfan01

    libsfan01 Guest

    hi all how can u create a conditional alert when the user tries to
    close the window or enters another url into the browser? i want to
    remind them to save changes.
     
    libsfan01, Aug 5, 2006
    #1
    1. Advertising

  2. libsfan01

    Randy Webb Guest

    libsfan01 said the following on 8/5/2006 7:11 AM:
    > hi all how can u create a conditional alert when the user tries to
    > close the window or enters another url into the browser? i want to
    > remind them to save changes.


    Let them suffer a few times of having to re-enter things and they will
    soon start making sure they save it. As for what you think you want to
    do, you can't reliably do it.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Aug 5, 2006
    #2
    1. Advertising

  3. It is possible but I strictly recommend you to not use this feature.
    You can simply
    atach alert function to onunload event handler on BODY tag for example.

    <script type="text/javascript">
    function myReminder(){
    alert("Do you save the changes?");
    }
    </script>
    </head>
    <body onunload="myReminder();">

    But it is very irritatingli for some users and not good decision about
    crossbrowser compatibility.

    libsfan01 напиÑа:
    > hi all how can u create a conditional alert when the user tries to
    > close the window or enters another url into the browser? i want to
    > remind them to save changes.
     
    Georgi Naumov, Aug 5, 2006
    #3
  4. libsfan01

    maya Guest

    Georgi Naumov wrote:
    > It is possible but I strictly recommend you to not use this feature.
    > You can simply
    > atach alert function to onunload event handler on BODY tag for example.
    >
    > <script type="text/javascript">
    > function myReminder(){
    > alert("Do you save the changes?");
    > }
    > </script>
    > </head>
    > <body onunload="myReminder();">
    >
    > But it is very irritatingli for some users and not good decision about
    > crossbrowser compatibility.


    and also very annoying when it gets used for asking you if you want to
    bookmark (or set as home pg on browser) the url you're leaving... in
    this case I think it would be more justified, maybe do it so users get
    reminded only the first few times they visit (can this be done just
    client-side? don't remember now...)

    >
    > libsfan01 напиÑа:
    >> hi all how can u create a conditional alert when the user tries to
    >> close the window or enters another url into the browser? i want to
    >> remind them to save changes.

    >
     
    maya, Aug 5, 2006
    #4
  5. Yes this can be done just client-side. If you want you can use cookie
    for store
    how many times the user was been ot this web page. Otherwise this way
    don't work if the user restrict cookies.
    maya напиÑа:
    > Georgi Naumov wrote:
    > > It is possible but I strictly recommend you to not use this feature.
    > > You can simply
    > > atach alert function to onunload event handler on BODY tag for example.
    > >
    > > <script type="text/javascript">
    > > function myReminder(){
    > > alert("Do you save the changes?");
    > > }
    > > </script>
    > > </head>
    > > <body onunload="myReminder();">
    > >
    > > But it is very irritatingli for some users and not good decision about
    > > crossbrowser compatibility.

    >
    > and also very annoying when it gets used for asking you if you want to
    > bookmark (or set as home pg on browser) the url you're leaving... in
    > this case I think it would be more justified, maybe do it so users get
    > reminded only the first few times they visit (can this be done just
    > client-side? don't remember now...)
    >
    > >
    > > libsfan01 напиÑа:
    > >> hi all how can u create a conditional alert when the user tries to
    > >> close the window or enters another url into the browser? i want to
    > >> remind them to save changes.

    > >
     
    Georgi Naumov, Aug 5, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry III
    Replies:
    2
    Views:
    605
    Kathy Burke
    Aug 3, 2003
  2. Matt Jensen
    Replies:
    1
    Views:
    5,240
    Matt Jensen
    Dec 16, 2005
  3. Jens Peter Hansen
    Replies:
    7
    Views:
    548
    Randy Webb
    Jun 19, 2004
  4. Shang Wenbin

    close current window using window.close()

    Shang Wenbin, Sep 1, 2005, in forum: Javascript
    Replies:
    10
    Views:
    382
    Gérard Talbot
    Sep 2, 2005
  5. HopfZ
    Replies:
    0
    Views:
    576
    HopfZ
    Aug 28, 2006
Loading...

Share This Page