• Register
  • Log In
  • Home
  • Quick Start
    • Configurator
    • Download YUI 3
  • Documentation
    • User Guides
    • Examples
    • API Docs
    • Environments
    • Tutorials
  • Community
    • Gallery
    • Blog
    • Forums
    • YUI Theater
    • Calendar
  • Contribute
    • YUI on GitHub »
    • File a Ticket
    • View Tickets
    • Dashboard
  • Other Projects
    • Shifter »
    • Yogi »
    • YUI 2
    • YUI Doc »
    • YUI Test
    • YUI Website
    • YUI Compressor »
    • YUI Builder »
    • YUI PHP Loader
    • Grid Builder »
    • Skin Builder »
  • YUI
  • >
  • Community
  • >
  • Gallery

Gallery

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • Yogi Documentation
  • Shifter Documentation
  • Developer Guide
  • Module Setup

Tag Cloud

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: 03/25/12
    + 0 -

    Adam Moore

    YUI Contributor

    See 4 more by this user.

    Created: 10/28/09
    Last CDN Push: 03/28/12
    Build Tag: gallery-2012.03.28-20-16
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.5.0pr4
    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:
    • event
    • beforeunload
    • 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.5.0pr4/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2012.03.28-20-16'
    }).use('gallery-beforeunload', function(Y) {
        Y.on('beforeunload', function(e) {
            e.returnValue = "Please don't go.";
        });
    });

    Forum Posts

    No forum posts for this module.

    © 2006-2013 Yahoo! Inc. All rights reserved.
    All code on this site is licensed under the BSD License unless stated otherwise.
    About This Site · Security Contact Info