You are here: Re: strange repeating of fwrite (because of javascript?) « PHP Programming Language « IT news, forums, messages
Re: strange repeating of fwrite (because of javascript?)

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация