Forum Moderators: coopster

Message Too Old, No Replies

new php function

         

ercantan

12:19 pm on Oct 5, 2009 (gmt 0)

10+ Year Member



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>

------------------------

Thank you to all friends
With best regards

tomda

12:26 pm on Oct 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are basically changing spacer.gif to big.gif once the page is loaded (well, not loaded - you should run this script once page is loaded only).

This can't be done with PHP since PHP is a server-side script while javascript is a user-side script.

The only thing you can do it to create a script in PHP that parses your HTML and change all "spacer.gif" to "big.gif" using some Regex or str_replace.

OR you could just rename big.gif to spacer.gif :) simpler !

ercantan

12:38 pm on Oct 5, 2009 (gmt 0)

10+ Year Member



thank you tomda.
you are right. im changing blank image (1 px) with big image after page loaded (yes you are right, not all page loaded).

Anyway, i just wanted to ask it. it will be great if we would do same thing with php.
thank you very much for your answer.
regards

andrewsmd

8:52 pm on Oct 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why is the image initially <img id="bigImage" src="images/spacer.gif"> if you change it to big right away? Can't you just rename it statically? If this is dynamic post some code and let's see if we can't find you a work around.