Page 1 of 1

javascript to php

Posted: Mon Oct 05, 2009 7:54 am
by ercantan
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

Re: javascript to php

Posted: Mon Oct 05, 2009 8:21 am
by jackpf
You can't.

Why not just change the image src?

Re: javascript to php

Posted: Mon Oct 05, 2009 8:26 am
by ercantan
Thanks for your answer. I have got a big image (100Kb) in header of main page. Browsers load this image firstly, after than load 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.

i just wanted to ask it. it will be great if we would make same thing with php.

thanks again.

Re: javascript to php

Posted: Mon Oct 05, 2009 8:43 am
by jackpf
Hmm...that's not normally how browsers work, I believe...

Normally, they load the CSS, Javascript, and other stuff in the <head> of the page, then the content (stuff in the <body>), then all other content, like flash...images...linked stylesheets (that aren't in the <head>)...etc.

But, no, you can't do this with PHP. PHP is server side.