EDIT: This question can be summed up as follows: How can two separate html pages, in separate windows, exchange information asynchronously?
For a class project, I have to build a web-based chat client. The professor provided a working server.
I have a portion of it up and running– any connected users can send messages to the server, and it will be relayed to all connected users and appear in their main chat window, chatroom-style.
However, the client is additionally required to have the option of sending/receiving private messages. If a private message is sent or received, a new window is opened, showing a chat interface for communication only with that user. Any future private messages sent/received by the client to/from that user will appear in this window instead of the main chatroom.
I’m at a complete loss. Having received a private message, how can I open a new window and then continue to communicate with that window? If more private messages are received from that user through the main window’s websocket connection, they must be sent to that window, and if messages are sent from that window to that other user, they must be relayed through the main window’s websocket connection.
How can this be done, if it can be done at all?
window.openreturns thewindowinstance belonging to the newly opened window. If the address opened in the new window acceptably falls in the same origin policy, you can modify it and its DOM just like you’d be able to modify the currently active window.