javascript to php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ercantan
Forum Newbie
Posts: 2
Joined: Mon Oct 05, 2009 7:49 am

javascript to php

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: javascript to php

Post by jackpf »

You can't.

Why not just change the image src?
ercantan
Forum Newbie
Posts: 2
Joined: Mon Oct 05, 2009 7:49 am

Re: javascript to php

Post 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.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: javascript to php

Post 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.
Post Reply