PDA

View Full Version : Window closing


renn
09-05-2002, 11:49 PM
My programming background is in perl/php etc.. having trouble with this simple javascript issue ..

Basically, the php app opens a new window and everything happens there, people have chat discussions with eachother etc..

My problem is that if a user clicks a link outside of their browser (outlook, IM,ICQ) which my customers use often, then the link loads into the chat session breaking the connection.

I cant simply have an unload message such as..

window.onbeforeunload = unloadMsg ;

function unloadMsg()
{
msg = "You are leaving the page, click cancel to stay."
return msg ;
}


because in my php code when someone enters a line of text, it accesses a second php file (wherein leaving the first page) and prompting the user if they want to leave the page.. and prompting again when it comes back to the initial chat page.

The solution is to somehow check the root domain of the incoming hyperlink and check that to our domain that we set in a variable.. if they are the same, ignore the command, else prompt the user with the above message explaining they are leaving the page..

Any suggestions on the coding would be greatly appreciated

Reggie

joh6nn
09-06-2002, 12:52 AM
onbeforeunload is an Explorer only event, so that won't work for more reasons than just what you listed.

unfortunately, you can't read the url of the incoming webpage. i think the best answer is for your clients to learn not to click so indiscriminately.

mordred
09-06-2002, 10:40 AM
Originally posted by renn
My problem is that if a user clicks a link outside of their browser (outlook, IM,ICQ) which my customers use often, then the link loads into the chat session breaking the connection.


I have troubles understanding this scenario. How do you get the information that a user clicked on his outlook icon on the desktop into your php chat sript? Maybe the term "the link loads into the chat" does confuse, as I'm not a very chat experienced person.

Perhaps you could tell us a little bit more about that because IMO it's the root of your problem and exactly knowing what happens will help helping you.

brothercake
09-06-2002, 11:37 AM
If a user has their browser preferences set to "use existing windows for launching shortcuts" then the phenomenon you describe may happen.

There is nothing you can do, unless you make your chat window a modalDialog window - which is also IE only

joh6nn
09-07-2002, 03:31 AM
the phenonemon he describes isn't a phenonemon. it has happened to me in IE, with the reuse windows option unchecked, and it always happens in Moz; there's no way to get new links to open in new windows. that's why i suggested that his clients become better users, instead of asking for more functionality. more functionality isn't a bad thing, but in this case, i don't think it's doable.

mordred
09-07-2002, 09:39 AM
Hm. I can't tell I've got the same experience as you joh6ann. All links on my desktop open nicely in new windows, both in IE5.5 and Moz1.0. But you're right, if the user has his settings tweaked to use existing windows, there won't be most certainly no workaround.