env3rt Posted October 19, 2007 Share Posted October 19, 2007 Is it possible to use a javascript event (ex: onUnload()) and combine it with php so it would be weird but maybe something like this <?php echo " <head> <script> function suber() {"; // EXAMPLE BELOW $expage="expage.html"; $fh = fopen($expage, 'w'); $expagewriting = "hey"; fwrite($fh, $expagewriting); fclose($fh); //EXAMPLE ABOVE echo " } </script> </head> <body onUnload='suber()'></body>"; ?> If you don't understand or can help please post Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/ Share on other sites More sharing options...
env3rt Posted October 19, 2007 Author Share Posted October 19, 2007 bump bump bump Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373587 Share on other sites More sharing options...
MadTechie Posted October 20, 2007 Share Posted October 20, 2007 please don't bump, unless an hour has passed, yes via ajax Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373603 Share on other sites More sharing options...
env3rt Posted October 20, 2007 Author Share Posted October 20, 2007 Sorry, I saw people bumping earlier tons of times so I thought it was allowed, how could you doing it with Ajax, example please Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373604 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 PHP can be used to send various variables into javascript. However they can't "trigger" a javascript call. Also php can't start off a call, but you can use javascript to call a php file, to do something. (as he said, using ajax). Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373605 Share on other sites More sharing options...
env3rt Posted October 20, 2007 Author Share Posted October 20, 2007 I wanted javascript to call php not php to call javascript Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373608 Share on other sites More sharing options...
MadTechie Posted October 20, 2007 Share Posted October 20, 2007 starting place.. http://www.phpfreaks.com/forums/index.php/topic,115581.0.html Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373610 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 @madtechie nice post, I think I will get some use out of that one as well. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373612 Share on other sites More sharing options...
MadTechie Posted October 20, 2007 Share Posted October 20, 2007 Thanks. Oh and as a note.. if a javascript function is added to a page.. php can call it (kinda) just echo "<script ..snip...>jsfunctionname();</script>"; Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373619 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 Yes, that is a very valid point. Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373621 Share on other sites More sharing options...
env3rt Posted October 20, 2007 Author Share Posted October 20, 2007 Oh and as a note.. if a javascript function is added to a page.. php can call it (kinda) just echo "<script ..snip...>jsfunctionname();</script>"; Yea that's what I was thinking. Quote Link to comment https://forums.phpfreaks.com/topic/74010-possible-to-trigger-php-using-javascript/#findComment-373622 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.