Marco Tabini schrieb:

> Ok, off the top of my head (please don't be upset if it doesn't work
> right off, because I'm doing this from memory):
>
> Web page:
>
> <script language=javascript>
>
> function checkimage()
> {
>         if (document.all.image1.width == 1)
>         {
>                 document.all.fr1.src="http://www.mysite.com/chat.php";;
>         }
> }
>
> function reloadimg()
> {
>         document.all.image1.src="http://www.mysite.com/img.php";;
>         setInterval ("reloadimg()", 2000);      // every 2 secs
> }
>
> </script>
>
> <body>
> <iframe name="fr1" src="chat.php">
>
> <img style="display=none" src="http://www.mysite.com/chat.php";
> onLoad="javascript:checkimage();">
> </body>
>
> In chat.php you simply push out whatever is in the database (the whole
> thing--or you come up with some method of just printing out what has
> changed since the last poll, which is trivial and beyond the point
> here).
>
> In img.php:
>
> <?
>
> function checkdb()
> {
>         // This returns true if new data is available
> }
>
> $filename = (checkdb() ? '1pixel.gif' : '2pixel.gif');
>
> header ("Content-type: image/gif");
> readfile ($filename);
>
> ?>
>
> 1pixel.gif is a one-pixel wide image, while 2pixel.gif is two pixels
> wide (it just occurred to me that you can't have a zero-pixels wide
> image, which would be quite pointless). The script basically reads in
> either file and spits it out after setting the content type.
>
> Once more, this script, as is, probably won't work because it was
> programmed in my messy head rather than in a proper PHP environment, but
> it should give you an idea of what needs to be done. In particular,
> remember to use the "display" CSS attribute rather than visibility so
> that the image will not take up any space on your page.
>
> Also, an apology--I seem to have mailed some messages twice by mistake.
> I was checking e-mail between eating my lunch and trying to get a tie on
> and things might have gotten a bit out of hand ;-)
>
> Let me know how it turns out!
>

Thanks, I will try that script as soon as I find some time, probably tomorrow.
But it seems to do the same thing as reloading would do: clicking all the time.
But I'll try it tomorrow.
Kind regards,
Oliver


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to