Why doesnt onbeforeunload()/onunload() execute this?

Discussion in 'JavaScript' started by imthebanana, Jun 27, 2011.

  1. #1
    Hay all,

    So i have been having some trouble with the following script:

    function userExit(){
    	var nameid = 'TrollFight';
       	var textid = '<?php echo $name; ?> left! Click next fight to continue!';
       	var answer = confirm("Leave The Fight?")
    	if (answer){
    		chat.send(textid, nameid);
    	}
    	else{
    		alert("Thanks for sticking around!")
    	}
    }
    
    HTML:
    Basically it is set to run onunload or onbeforeunload, i know chat.send works outside these functions, and it allows the confirm popup to appear, but it doesn't seem to run the chat.send function

    any ideas?

    Cheers

    Alex
     
    imthebanana, Jun 27, 2011 IP