xmen33 Posted July 5, 2009 Share Posted July 5, 2009 hii had a chati went to code to make thiswhan i close the window of chatdelete some row in databasei make code but it dont work with Safari !code (file mahmoud.php) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> <script type="text/javascript"> function logout(){ xmlHttp=GetXmlHttpObject() var url="mahmoud.php?" url=url+"logout=logout" xmlHttp.open("GET",url,true) xmlHttp.send(null) } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } </script> </head> <body onunload="java script:logout()"> <?php $connect_m_chat=mysql_connect("localhost","root","root"); mysql_select_db('my_chat',$connect_m_chat); if($_GET['logout']=='logout'){ mysql_query("DELETE FROM mahmoud_messages WHERE MessageID>1"); } ?> </body> </html> and all other browser work very goodso what is the problem or can any one game me other code?thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted July 5, 2009 Share Posted July 5, 2009 Don't put the "javascript:" before event handlers, just write the function to execute. The browser knows that you're using Javascript there. Link to comment Share on other sites More sharing options...
xmen33 Posted July 5, 2009 Author Share Posted July 5, 2009 ok i do that but still Safari dont work and ie7 ff Google Chrome work very good !so what is the problem? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 5, 2009 Share Posted July 5, 2009 Have the PHP script write out some debug information to a log or something, to make sure that it's actually getting executed. Closing the window might cancel the request in Safari or something. Use the PHP script to debug that. Link to comment Share on other sites More sharing options...
xmen33 Posted July 5, 2009 Author Share Posted July 5, 2009 i dont understand what you mean by that? Link to comment Share on other sites More sharing options...
morrisjohnny Posted July 5, 2009 Share Posted July 5, 2009 My interpretation of JustSomeGuys's response is that maybe Safari is excuting the code, But closes before the code can be completed for one reason or another. Where's the other broswers may be waiting untill the code is completed. so using the php debug functions will show you whats happening when closing the window. Link to comment Share on other sites More sharing options...
xmen33 Posted July 5, 2009 Author Share Posted July 5, 2009 whan i do alot search i get thatSafari and opera dont supportso any help in this? Link to comment Share on other sites More sharing options...
Ingolme Posted July 5, 2009 Share Posted July 5, 2009 Try testing both the "unload" and "beforeunload" events to see if some browsers might use the other. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.