for u who need code to end some session, u can try this javascript code :
function ajaxDone(tgt) {
if (creq.readyState == 4) {
if (creq.status == 200 || creq.status == 304) {
//end of execute page
Alert("Thanks You For Chat With Us");
} else {
}
}
}
window.onbeforeunload = exitCheck;
//when user close the page or browser this function will called
window.onunload = test;
//this function call another page using AJAX so u not need POPUP
function test(){
if (window.XMLHttpRequest) {
creq = new XMLHttpRequest();
creq.onreadystatechange = function() {ajaxDone(target);};
creq.open("GET", "page_to_end_your_session.php", true);
creq.send(null);
// IE/Windows ActiveX version
} else if (window.ActiveXObject) {
creq = new ActiveXObject("Microsoft.XMLHTTP");
if (creq) {
creq.onreadystatechange = function() {ajaxDone(target);};
creq.open("GET","page_to_end_your_session.php", true);
creq.send(null);
}
}
}
function exitCheck(evt){
//Get confirmation from user are they want to exit or not
return "Are You Sure To Exit This Session?"
}
any coments is welcome
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar