www.webdeveloper.com
Results 1 to 3 of 3

Thread: window.onbeforeunload and Firefox (AJAX)

  1. #1
    Join Date
    Aug 2006
    Posts
    119

    window.onbeforeunload and Firefox (AJAX)

    Any ideas if the method window.onbeforeunload and window.onunload has to be set in some different manner for IE and FF??

    I have this script:
    Code:
    .....
    <% If len(request.QueryString("udar"))>0 then %>
    	window.onbeforeunload = unloadPage1;
    <% End if %>
    function unloadPage1()
    {
    	var url="duel.asp";
    	url=url+"?q=<%= request.Cookies("name") %>";
    	url=url+"&sid="+Math.random();
    	url=url+"&gone1=yes";
    	http.open('GET',url,true);
    	http.onreadystatechange = updateNewContent;
    	http.send(null);
    	opener.window.location="online.asp";
    }
    and server side:
    Code:
    .....
    If request.QueryString("gone1")="yes" then
    	dim fs,f, filenm
    	'filenm=replace(application("duel"),"|","_")&".txt"	
    	set fs=Server.CreateObject("Scripting.FileSystemObject")
    	set f=fs.GetFile(Server.MapPath(replace(application("duel"),"|","_")&".txt"))
    	f.Delete(true)
    	set f=nothing
    	set fs=nothing
    	application("finished")=""
    	application("duel")=""
    	application("p1")=""
    	
    end if
    So in IE this setup works perfect all the sessions are cleared, the file is deleted and the opener window get refreshed.
    But in FF nothing heppens, only the opener window gets refreshed but no changes to the session variables and file exsitense is done.

    Ane clues to this problemm?

  2. #2
    Join Date
    Jul 2008
    Posts
    1
    I know this post is a bit late .... but i had the same prob.

    The problem is that firefox is continues with the unload before the ajax call is actually finished. So Change the ajax request to async:

    Code:
    http.open('GET',url,false);
    Now it should work in FF

  3. #3
    Join Date
    Aug 2006
    Posts
    119
    Wow yeah thats old 1

    Thanks you anyways but I gave up on that project pretty long ago got to tiered of it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles