Hi Everbody,

Have you idea about chat-

I am facing some type of problem related to chat.
How to open a div or popup when anybody send message, like gmail chat system.

Thanks, in advance


8 Years
Discussion Span
Last Post by digital-ether

Well generally chat applets/applications are done by client side software such as Java/Ajax. But if you want it to be done in php, it won't be the fastest and may cause extra cpu usage of the server if it is done by php. So to do it with php, you would need an iframe which refreshes once every 2000 milliseconds (2 seconds) and gets an update on if there are any new messages. Then if a new message is detected, the php script passes onto a javascript the signal which causes the entire page (target=_top) to refresh or as you have suggested, just for another window to popup with the new message. And if the entire page is refreshed, it can retrieve all the messages from the conversation through a mysql database with one column being the logon id which all people in the same conversation share the same id. Hope that theory helps.


i built one a few months back. look here. it still has a test script up. this one was made for people who wanted a chat but didn't have access to a database. it can be modified to do anything. i currently trying to find time to add features like admin functionality and smilies ect.


I have read the information from the link and the reason why you were able to not use databases and have better live streaming is because you used ajax where as my theory in post #2 was done in pure php and javascript. And that is when the sentence below which I mentioned in post #2 explained that it would be better in ajax/java

Well generally chat applets/applications are done by client side software such as Java/Ajax.

So basically a database is only required if you don't use a client side language that can communicate with another computer.


sorry, i saw that the thread title "php chat" and figured i would give an example of one. i didn't know it was a debate over which method is better.

obviously languages like java can handle a task like this with ease. i was just trying to show other methods on how it can be done.

i created the script to not use a database on purpose. i did it for people that don't have access to a database, like i mentioned in my other post. i can easily integrate a database into it and get better performance. i never said i couldn't use a database. ??? i used ajax because i hate iframes and the annoying refresh you get when you set a chat up like that. and yes i have made a chat like you mentioned.


talkwithtarique, Is the problem with actually opening a popup?

A popup window can be opened in javascript with the window.open() method.
A div, can be create dynamically via DOM methods. The way it floats, like in Gmail, is through CSS styling (notably the position:aboslute or position:fixed properties).

Is this what you are asking for?

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.