URGENT!Get the refresh event of the browser!

I want to show popup when client close window and goes to another domain. I am trying to use onunload event but it also gives popup when i refresh the site and goes to any link on my site only. Is there is any way to get that whether it is a refresh event or any working way will help me.

Waiting For reply it’s urgent.:frowning:

Hi there,

I’ve looked in to something like this before, and it isn’t possible to tell whether the client is refreshing the page or closing it. The best you can probably do is set a cookie so that people will only see this popup once.

I will also add that unless there is a very good reason to use the onunload event to show a message, it should probably be avoided as it will degrade the user experience and usability of your website. When a user closes your website, they are making a conscious decision about what action they are taking, they are leaving for a reason. When then forcing someone to close an additional popup you are mentally throwing them back a step and creating frustration and maybe even anger with a user.

Simple things like this could be the difference between these users returning to your website or not.

When is your dead line?

No point in me spending time posting a possible solution if your dead line has passed or if you have got a suggestion on another website since your request is “urgent”.

The on unload event is too late for you to be able to achieve anything. I think that it it the onbeforeunload event that you are wanting to use.

It is not possible to determine the reason wh the page is loading. It could be because the page is being closed, or refreshed, or a link is being loaded, or they are navigating to another part of your site.

A possibly useful technique could be to monitor the onclick event for when they click on a link to somewhere that is not on your site. If it’s to some other site, you can raise a flag that indicates as such, so that the onbeforeunload function can then check that flag and take action if that’s the case.

Ya we know that it will irritates the user but we really want to do a survey that why we are do it for a particular time. If I put cookies it will show popup for once but i don’t need i hope you understand why…

Hey, thankyou.

If you know the possible answer I am eagerly waiting for it. Sorry for not replying earlier because i was busy for some short of business meeting.

Ya i have tried this event also but how would i know that it’s a refresh event? I can possibly do the navigation thing.

That’s the difficulty. It’s not possible to know if it is a refresh event.

I’ve been through this exact scenario for a government website a short while ago, they also wanted an exit survey.

Because of the futility of trying to get a “nice” implementation of this and many usability and accessibility concerns that I pointed out to them.
We ended up using a “survey” button that’s anchored to the left side of the screen and a call to action on the home page for the first month the survey is online. This button would in turn open a modal window (and degrade gracefully by going to a separate survey page when javascript is disabled)

I can see if I can find an example if you’re not sure of what I mean :slight_smile:

Means It’s not possible to do so. :frowning:
Hey thanks may be i should go for any other option for doing survey.

I got it what are you trying to say. I also like this idea. See if you can provide me any example that would be great help to me. :slight_smile:

I couldn’t find the website that initially inspired and figured I’d just quickly mock it up as a wireframe so you can at least get a bit of an idea :slight_smile:

Attached to this post is an interactive PDF with wireframes that demo the (very very basic) flow of the survey. (Also available at http://afterlight.com.au/sitepoint/posts/804858-URGENT_Get-the-refresh-event-of-the-browser/SurveyButtonExample.pdf)

Got it…Thanks a lot…:slight_smile: