Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

site exit popup

  • 03-07-2007 8:06am
    #1
    Registered Users, Registered Users 2 Posts: 648 ✭✭✭


    hi
    i found this script that creates a popup on exit of the page
    http://www.nowsell.com/pop-ups/exit-popup-scripts.html

    however i need to create popup on exit of the site and not each and every page

    does anyone know how to do this ?

    tnx


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    Are you talking about when the user clicks a link to leave the site, or closes the browser or types a new url in the address bar?


  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭ChicoMendez


    Ph3n0m wrote:
    Are you talking about when the user clicks a link to leave the site, or closes the browser or types a new url in the address bar?

    good question - either/any of the above
    ideally a solution that would capture any of the above (but i dont think its possible to detect the latter??)

    closing the browser window might be only one we can detect (correct me if im wrong) ?

    tnx


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    http://www.hasbro.com/transformers/en%5FGB/ - bottom left side, the "official movie site" link is a pop up exit script, that should prove useful

    However its only for exit links from a site - you could also try and combine the popup function with an onclose method

    This also might help aswell - http://www.geocities.com/z0z0z02003/leave.htm

    However if people have popup blocker activated - this makes it kind of redundant


  • Registered Users, Registered Users 2 Posts: 872 ✭✭✭grahamor


    There is a method called onBeforeUnload that fires when the page is closed.

    Check out this link, you get an alert when you close the browser tab

    http://www.4guysfromrolla.com/demos/OnBeforeUnloadDemo1.htm


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    onBeforeUnload is IE and FF only

    Assuming that internal links are relative (i.e. that you can distinguish external ones by checking for http:// at the start), you can do this using jQuery:

    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript">
    function yourUnloadAlert(internalLink) {
    $(window).unbind("unload");
    if (internalLink==true) {
    return;
    }
    alert("this should trigger for external links and window.unloads");
    }

    $(document).ready(function() {
    $(window).one("unload", function() {
    yourUnloadAlert(false);
    });

    $("a").each(function() {
    linkURL=$(this).attr("href");
    if (linkURL.indexOf("http://")==-1) {
    $(this).click(function() {
    yourUnloadAlert(true);
    });
    };
    });
    });
    </script>


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭ChicoMendez


    liam,

    that sounds like a nice solution
    however im getting je error:

    Error: $(window).one is not a function

    tnx


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Did you download and link to jQuery ?

    http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.1.3.pack.js

    Sample page with the above script working

    http://www.onsight.ie/test.html


  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭ChicoMendez


    yes i had downloaded jquery

    however one issue is that im using a CMS that generates the urls (so all the urls have http://www. even the 'relative ones)
    hmmmmm


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Then reverse the "http://&quot; indexOf comparison and use the name of the current server (e.g. "http://www.yourserver.com")

    :
    if (linkURL.indexOf("http://www.yourserver.com")==0) {
    :

    Did you manage to get jQuery working ?


Advertisement