SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Location
    Mumbai
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    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.
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pankaj.kumar6401 View Post
    Waiting For reply it's urgent.
    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".

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by pankaj.kumar6401 View Post
    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.
    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Member
    Join Date
    Dec 2011
    Location
    Mumbai
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AussieJohn View Post
    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.

    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..

  6. #6
    SitePoint Member
    Join Date
    Dec 2011
    Location
    Mumbai
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by webdev1958 View Post
    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".
    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.

  7. #7
    SitePoint Member
    Join Date
    Dec 2011
    Location
    Mumbai
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    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 i have tried this event also but how would i know that it's a refresh event? I can possibly do the navigation thing.

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by pankaj.kumar6401 View Post
    Ya i have tried this event also but how would i know that it's a refresh event?
    That's the difficulty. It's not possible to know if it is a refresh event.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    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
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  10. #10
    SitePoint Member
    Join Date
    Dec 2011
    Location
    Mumbai
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    It's not possible to know if it is a refresh event.
    Means It's not possible to do so.
    Hey thanks may be i should go for any other option for doing survey.

  11. #11
    SitePoint Member
    Join Date
    Dec 2011
    Location
    Mumbai
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AussieJohn View Post
    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
    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.

  12. #12
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    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

    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/p...tonExample.pdf)
    Attached Files Attached Files
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  13. #13
    SitePoint Member
    Join Date
    Dec 2011
    Location
    Mumbai
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it..Thanks a lot..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •