php and html is not the optimal way to do that (because receiving a html page is a pull and not a push process).
anyway... you need a database or at least a textfile on your server. whenever someone views your chat-page you store his IP into the database. Now you have a list of chat participants. You'll need a timeout mechanism too because you won't recognize if someone closes the browser window or goes to another page.
from now on it easy: add an invitation colum to your chat participants table in the database. Set a flag there for each user that should receive an invitation.
The chat-page does a reload every few seconds and calls a PHP script that checks if an invitation flag is set for this IP in the database. In that case you just output a bit of JS/HTML code that opens a popup on the client side and update the invitation flag so the user won't get the invitation again and again...
the rest is up to you ... and of course quite a piece of work ;-)