SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast navtej's Avatar
    Join Date
    May 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I want ot capture Blowser Close event.

    Hi friends

    I have an web application, when a user exit using the [ X ] on the top right of the browser. I want to open a conformation box equring abt the descion of the user.

    The main problem is my function is not 100% sure if a user has realy exited , or is doing something else, eg : 'refersh' its the ambugity.

    I am lokking for something which is 100% sure .

    Currently I am doing with javascript on page un load , the problem is the event is not being caputuerd on the client side on the broser , even though I am able to capute it on unload on the server, the function fires on even page refresh and when when ever a user manualy changes the address in the browser address manualy. Though I have filterd the events fired by input,image and A tags tha app is not 100% perfect.

    heres the code

    on unload:
    onunload=con

    Javascript:


    var SopingMode_clicked = false; // to be made true if the checking condition is met by the app.

    document.onclick = function(e)
    { alert("hi");
    var nn6=document.getElementById&&!document.all;
    var SopingMode_e = (nn6==true) ? e.target : event.srcElement;
    alert(SopingMode_e.tagName+"event");
    if(SopingMode_e.tagName == "A" || SopingMode_e.tagName == "INPUT" || SopingMode_e.tagName == "IMG")
    { SopingMode_clicked=true;}
    }



    var win=window;
    var exit=true;
    function con()
    {
    (window.closed+"W "+win.closed+"W "+window.close+"-"+window+" e "+exit+"e ");

    if(ShopingMode_InCart)
    {
    if (exit)//if(window.closed)
    {
    if(SopingMode_clicked)
    {
    }
    else
    {
    if(confirm("There are items in the shopping acrt are you sure you want to exit !"))
    {
    }
    else
    {
    var der=document.URL;
    window.open(der,'navtej',"");
    }
    }
    }
    }
    }

    the code is working fine the prolem is with ambugity.

    Thanks.

  2. #2
    SitePoint Enthusiast navtej's Avatar
    Join Date
    May 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am able to do it with 100% accuarccy in IE with js

    with the follwoing code run on page onload

    function HandleOnClose() {
    if (window.event.clientX<0 && window.event.clientY < 0) {

    window.open('http:www.google.com','Exit','toolbar=No,status=yes,scrollbars=yes,width=550,height=400');
    }
    }

    but in mozilla its still a problem

  3. #3
    SitePoint Enthusiast Tygatur's Avatar
    Join Date
    Apr 2006
    Location
    Germany
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would you like to explain yourself, if you leave a homepage?

    You can't force your visitors to stay.
    But you can include a guestbook on your homepage to leave comments.
    Otherwise it's very user-unfriendly and would you like to surf on such a site?

    If you really want to have visitors, then show them interesting content.
    Give them a REAL reason to look at your page and to return.
    to code or not to code ?
    that's too much of a question for a signature.

  4. #4
    SitePoint Enthusiast navtej's Avatar
    Join Date
    May 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Tygatur
    Would you like to explain yourself, if you leave a homepage?

    You can't force your visitors to stay.
    But you can include a guestbook on your homepage to leave comments.
    Otherwise it's very user-unfriendly and would you like to surf on such a site?

    If you really want to have visitors, then show them interesting content.
    Give them a REAL reason to look at your page and to return.
    thnaks for ur comments i appriciate, actually the sonario in which I going to use it is when a user has put some things in the shopping cart and then if he
    closes the browser , only a confirmation opens to know the choice of the user wheather he want to leave or stay.


Bookmarks

Posting Permissions

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