YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub
  • Home
  • Gallery
  • Forums
  • YUI 2
  • YUI 3
  • YUI Labs
  • YUI Compressor
  • More
  • Gallery Forums
  • Gallery Stats
  • Gallery Calendar
  • Register
  • Login

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • FAQ
  • Developer FAQ
  • Developer Guide
  • Module Setup

Tag Cloud

plugin foxxtrot tivac event adam nzakas ajax yui2 jafl overlay jsonp ericf io node port slideshow jacobfogg davglass caridy skinnable widget rgrove lsmith animation apipkin form

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    beforeunload (gallery-beforeunload) on cdn

    Last Updated: 10/28/09
    + 0 -

    Adam Moore

    YUI Developer

    See 4 more by this user.

    Created: 10/28/09
    Last CDN Push: 11/2/09
    Build Tag: gallery-2009.11.02-20
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.0.0
    Free for use.

    The beforeunload event is not standard, yet it is useful enough to support as well as we can. Browsers are not consistent about how the event operates, and some browsers do not support it at all. This module supplants any existing DOM0 onbeforelistener because DOM2 style listeners won't work across the A grade at this time.

    You can attempt to prevent the user from leaving the page by setting the returnValue property on the event object. The user will be presented with a dialog to see whether or not they want to allow you to prevent the page navigation. If a message is included in the returnValue property, it is added to the dialog in addition to what the browser normally displays.

    • Tags:
    • beforeunload
    • event
    • adam
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    The following code will attempt to prevent the navigation away from the page. The user will be presented with a dialog that will include the text provided in e.returnValue.

    Code Sample

    <script src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2009.11.02-20'
    }).use('gallery-beforeunload', function(Y) {
        Y.on('beforeunload', function(e) {
            e.returnValue = "Please don't go.";
        });
    });

    Forum Posts

    No forum posts for this module.

    YUI Projects
    • All YUI Downloads
    • YUI 2
    • YUI 3
    • YUI Doc
    • YUI Compressor
    • YUILibrary.com
    • YUI Build Tool
    • YUI PHP Loader
    YUI Labs
    • All YUI Labs Projects
    • Yeti
    Pages & Links
    • All YUI Downloads
    • Git FAQ
    • Graded Browser Support
    • Contribute to YUI
    • Forum Stats
    • Gallery Stats
    • YUI Calendar
    Contribute
    • Submit a Bug
    • Request a Feature
    • Write Code
    • Meet the Team
    Follow YUI
    • on GitHub
    • on Twitter
    • on FriendFeed
    • on Facebook
    • on IRC
    • YUI Blog
    • YUI Theater
    • YUI Forums

    © 2010 YUI Library - Site Credits