Re: Chat with php
| From: | Oliver Witt | Date: | Mon, 07 Oct 2002 18:44:08 +0000 |
| Subject: | Re: Chat with php | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-119126@lists.php.net to get a copy of this message | ||
Marco Tabini schrieb:
> Simple trick (well, not so simple, but kind of a Columbus' Egg):
>
> 1) Create an <img> tag in your web page that is hidden
>
> 2) Point the img tag to a php script that returns:
>
> 1) An image with a pixel width of 1 if there is new data to pick
> up from the server
> 2) An image with a pixel width of 0 otherwise
>
> 3) Create a javascript that refreshes the image every second (or every
> two seconds, or however often you feel necessary--the more often, the
> more responsive and "real time" your chat system will be).
>
> 4) Add an OnLoad event to the img tag that points to a Javascript that
> checks the width of the newly reloaded image. If the width is one, then
> you reload your chat text content (which you may want to put in an
> iframe to avoid having to reload the whole page).
>
> I don't have a script to show unfortunately, as it would probably be too
> complicated and long for the list (and I have no time to write
> it...<sigh>), but hopefully, this will give you the gist of it.
>
> Cheers,
>
> Marco
>
Okay, that sounds like something i can do, i just need to know how to hide
and how to point the img tag at something.
Olli