ercantan Posted October 5, 2009 Share Posted October 5, 2009 Hi all, i ve got a javascript code. but i want to use a php function instead of this javascript code. You know, some people block javascripts, due to this reason i would like to use server side coding. However, i could not write a php function yet. Any help would be great for me. here is my java script code: <html> <body> <table> <tr> <td> <img id="bigImage" src="images/spacer.gif"> <--! my other contents. !--> </td> </tr> </table> <script type="text/javascript"> function LoadImage() { if (document.getElementById("bigImage")) { document.getElementById("bigImage").src="images/big.gif"; } } LoadImage(); </script> </body> </html> ------------------------ Acutually, im using this javascript code in php file. i wrote codes in html to show you basicly. Thank you to all friends With best regards Quote Link to comment https://forums.phpfreaks.com/topic/176562-javascript-to-php/ Share on other sites More sharing options...
Adam Posted October 5, 2009 Share Posted October 5, 2009 To be honest I don't really see what this code would be used for? Could you explain what you're trying to do a little better? Quote Link to comment https://forums.phpfreaks.com/topic/176562-javascript-to-php/#findComment-930749 Share on other sites More sharing options...
ercantan Posted October 5, 2009 Author Share Posted October 5, 2009 Hi MrAdam, Thanks for your answer. I have got a big image (100Kb) in header of main page. Browsers load this image firstly, after than loads other content. so, it takes really long time. i think, waiting this image is fully unneeded. with this javascript, browser load small blank image (1 pixel) firstly, after than loads other contents, and finally, change small image to big image. thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/176562-javascript-to-php/#findComment-930754 Share on other sites More sharing options...
kickstart Posted October 5, 2009 Share Posted October 5, 2009 Hi Not really any way to do it beyond what you have. Once the page has loaded that is the end of php for that page. You can use AJAX to call php from a loaded page, but that too relies on javascript. You could possibly use CSS to set the image, as that should happen once the page is loaded. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/176562-javascript-to-php/#findComment-930778 Share on other sites More sharing options...
Adam Posted October 5, 2009 Share Posted October 5, 2009 Unfortunately there's no PHP alternative to that code. It relies on being able to modify the DOM after the page has loaded- which PHP cannot do (as it's processed server-side before you start loading the page). I wouldn't rely on JavaScript for this either to be honest, as you say users could disable it. The best solution I think would be to try to lower the file size of the image. Perhaps try lowering the quality of the image (whilst it doesn't visually loose quality), and try using image optimization tools like Smuth.it. Quote Link to comment https://forums.phpfreaks.com/topic/176562-javascript-to-php/#findComment-930781 Share on other sites More sharing options...
ercantan Posted October 5, 2009 Author Share Posted October 5, 2009 thank you very much for your answers and your times. I just wanted to learn it. and i got answers. i will use javascript. regards Quote Link to comment https://forums.phpfreaks.com/topic/176562-javascript-to-php/#findComment-930786 Share on other sites More sharing options...
lynwell07 Posted October 8, 2009 Share Posted October 8, 2009 I just wanted to ask if how we would develop java applet games and use them as clients, and have people play the games against each other? _________________ Landing page optimization Quote Link to comment https://forums.phpfreaks.com/topic/176562-javascript-to-php/#findComment-932812 Share on other sites More sharing options...
kickstart Posted October 8, 2009 Share Posted October 8, 2009 Hi Do you mean Java or Javascript? They are VERY different. In either case you should be able to connect up to databases, but in very different ways. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/176562-javascript-to-php/#findComment-932871 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.