simmsy Posted January 10, 2012 Share Posted January 10, 2012 Hi im having trouble trying to get the javascript method 'onbeforeunload' into a php statement. What I wanted was if the user clicks refresh or closes the browser then update a table in mysql. Can anyone help with the code im not sure where to start? thanks Quote Link to comment https://forums.phpfreaks.com/topic/254754-trouble-implementing-javascript-into-php/ Share on other sites More sharing options...
kicken Posted January 10, 2012 Share Posted January 10, 2012 The best you can do is have your JS code for onbeforeunload fire off an ajax request to a PHP file. The browser may or may not run it, there's nothing you can do about that. Don't make anything depend on it. Quote Link to comment https://forums.phpfreaks.com/topic/254754-trouble-implementing-javascript-into-php/#findComment-1306288 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.