homepage Welcome to WebmasterWorld Guest from 54.145.183.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Open New Window On Close of Original Window
Open window on close of originial window javascript
mcohen

10+ Year Member



 
Msg#: 399 posted 11:12 pm on May 9, 2003 (gmt 0)

I need to open a new window when the browser is closed, and that's it, not when changing pages. I've tried quite a few things from various tuturials and posts and nothing has worked. Everything I've tried has been in javascript, but nothing has worked.

Thanks for any help,

Mike

 

ShawnR

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 399 posted 11:50 pm on May 9, 2003 (gmt 0)

Hi Mike and welcome to WebmasterWorld!

I'll make you a deal: I'll tell you how, then you have to answer a question. OK? So here is how:


You can set a variable when the page loads. Say:

visitor_is_leaving = true;

In all your <a...> tags, you include:
onclick="javascript:visitor_is_leaving = false;"

In your <body...> tag you include:
onunload="javascript:if (visitor_is_leaving){ code to pop up your new window};"

OK, now your end of the bargain. My question is why do you want to do this? Pop-ups on exit are quite a common request, and I don't understand why, so perhaps you can help me. Don't people realise that it just iritates visitors and hence makes them just slightly less willing to visit your site again, and also unwilling to buy anything from the site you are popping up? Anti-pop-up software has really prolifereated lately, and the number of people who turn off javascript on their browsers is relatively high (9 or 10%). Both phenomenon have occurred to combat this sort of practice, and it is a shame, because javascript used well can really improve a visitor's experience of the site. So please help me understand why people are still trying to do pop-ups on exit.

Shawn

mcohen

10+ Year Member



 
Msg#: 399 posted 8:07 am on May 10, 2003 (gmt 0)

Shawn,

The reason is I've got a small php based site administration area that the client must login to access. In windows, when you close the browser, the session ends and the next time they access the admin area they are prompted with a login. Apparently on a Mac, the session doesn't end when the browser closes, so when they return, they waltz right in, without having to login, making them feel it is less secure. I have a logout link that logs them out, but apparently that is just way too inconvenient to use, so I'm trying to develop a fail-safe way of logging them out when the browser window is closed.

Is there no way more simple than adding a variable to all the links to accomplish this?

Thanks for your input.

Mike

ShawnR

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 399 posted 9:40 am on May 10, 2003 (gmt 0)

Hi Mike

Sorry I misjudged your intent.

So what you really want to do is destroy the session when the browser moves off your site, not bring up a pop-up. Yes?

I'm not an expert in php sessions, but my intuition is as follows: It might be that the visitor on a Mac who noticed the phenomenon you describe allowed your cookie to be stored, whereas Windows visitors did not. i.e. It might have to do with the security settings on the visitor's machine, and not related to whether they are using a Mac or Windows machine. I'd suggest you have a look at the php manual for entries related to the "session.cookie_lifetime" setting in your "php.ini" file. Also look at the manual entries relating to session_start, session_unset, session_destroy. Hopefully someone with more knowledge on sessions will be able to shed more light.

Bear in mind also that it is not a good idea to rely on Javascript for anything related to security.

Shawn

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved