aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes how to identify a window close and a window refresh event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to identify a window close and a window refresh event" Watch "how to identify a window close and a window refresh event" New topic
Author

how to identify a window close and a window refresh event

Rohit Rai
Ranch Hand

Joined: Aug 04, 2008
Posts: 53
Hi!

I have been looking around but could not get any idea as to how to differentiate between a close event and refresh event using JavaScript. As the onUnload event is called both the time. i.e. if the user closes the window and also if he/she refreshes it.
Any idea as to how to go about?

Regards,

Rohit
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There is no way to do it.

Eric
Rohit Rai
Ranch Hand

Joined: Aug 04, 2008
Posts: 53
Hi Eric !

Yup I think so.

Regards,

Rohit
suresh dasari
Ranch Hand

Joined: Oct 05, 2009
Posts: 121

Hey guys, I am trying to achieve the same thing, but couldnt do it.

any help is appricieated.


Sun Certified Java Programmer with 93 percent
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

As has already been said, it cannot be done. It doesn't matter how badly you need it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
suresh dasari
Ranch Hand

Joined: Oct 05, 2009
Posts: 121

Hi guys,

I fount a partial solution.
I mean refresh can be done in 2 ways
1) clicking F5 button
2) browsers refresh button.

I found solution for F5 button.
but browsers refresh is pending.

any ways my requirement is only F5 because we is hiding the browser refresh button.
Georgiana Lungu
Ranch Hand

Joined: May 17, 2010
Posts: 34
I have noticed that if a bean instantiated in the page we want to check for refresh, then, if a page is opened for unload, in that page request.getAttribute("bean_name"); returns null if browser with the first page was closed and returns not null if the browser was just refreshed. Please correct me if i am missing somethign.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

What do server-side beans have to do with JavaScript events?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to identify a window close and a window refresh event