|
Posted by tihu on 04/25/06 00:33
Nate Murray wrote:
> Hey all, I'm having a strange PHP (4.3.10) problem that seems to have
> something
> to do with javascript. This is a bit complex, so hold on to your hats.
>
>
> <html> <head> <title>Writing Twice</title>
>
> <script language="JavaScript">
>
> function preloadImages() {
> img = new Image;
> img.src = "";
> // img.src = "img.gif";
> }
>
> </script>
>
> </head>
Hey there
You were spot on about it being javascript, I think the problem is
img.src='';
Done a quick test and it seems both firefox and explorer refuse to let
img.src be a blank string and automatically set img.src to something
nonblank if you try. In firefox img.src was set to
'http://server/pagedir/testpage.html' immediately after img.src='', in
explorer img.src was 'http://server/pagedir/'. (it was x.gif before)
Do alert(img.src) just after img.src='' on your page to see what I
mean.
I think this is why the php script will be called twice, once when you
open the page in your browser, the second time when the setting
img.src='' ends up trying to get the current page (why? silly
browser..)
The solution is set img.src to anything else apart from a blank string,
even setting img.src to a fake filename of an img that doesnt exist
should be ok. I hope..
Seeya
Tim
Navigation:
[Reply to this message]
|