Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

some help with JavaScript

Status
Not open for further replies.

AT76

Technical User
Apr 14, 2005
460
US
Hi all,

I've never coded in JavaScript and I need some help.

What I want is a message to pop up if a user tries to close the window manually by clicking on the 'X'. And lastly to not close the window after the popup is displayed. Could someone please help me with this?

Thanks a bunch!
 
Sorry AT76, this is completely impossible. And a good thing too, imagine visiting a website that didn't allow you to close your browser. How annoying would that be?

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
ok kaht... Is it possible then to have a message pop up when they try to close the window? Then not allow them to exit until a condition is met?
 
So you want to not allow people to close their browser window?

Or do you just want to make certain information gets updated before the page closes?

In IE you have the onbeforeunload event but for other browsers you have to take a different approach.

Look at the link below for an example.

At my age I still learn something new every day, but I forget two others.
 
Hi theniteowl, what I'm trying to do is to make the user take a quick quiz without exiting the window. Then I want the user to click submit instead of closing the window.

Is there a way to do this?
 
No. You cannot prevent the window from closing, you can only execute a function prior to it closing.
That function can popup your quiz window but it cannot enforce that they complete it before closing or force them to click a specific button on your page.


At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top