Blame jquery/jquery.ba-1.3-hashchange.js

Packit 1c1d7e
/*!
Packit 1c1d7e
 * jQuery hashchange event - v1.3 - 7/21/2010
Packit 1c1d7e
 * http://benalman.com/projects/jquery-hashchange-plugin/
Packit 1c1d7e
 * 
Packit 1c1d7e
 * Copyright (c) 2010 "Cowboy" Ben Alman
Packit 1c1d7e
 * Dual licensed under the MIT and GPL licenses.
Packit 1c1d7e
 * http://benalman.com/about/license/
Packit 1c1d7e
 */
Packit 1c1d7e
Packit 1c1d7e
// Script: jQuery hashchange event
Packit 1c1d7e
//
Packit 1c1d7e
// *Version: 1.3, Last updated: 7/21/2010*
Packit 1c1d7e
// 
Packit 1c1d7e
// Project Home - http://benalman.com/projects/jquery-hashchange-plugin/
Packit 1c1d7e
// GitHub       - http://github.com/cowboy/jquery-hashchange/
Packit 1c1d7e
// Source       - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.js
Packit 1c1d7e
// (Minified)   - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.min.js (0.8kb gzipped)
Packit 1c1d7e
// 
Packit 1c1d7e
// About: License
Packit 1c1d7e
// 
Packit 1c1d7e
// Copyright (c) 2010 "Cowboy" Ben Alman,
Packit 1c1d7e
// Dual licensed under the MIT and GPL licenses.
Packit 1c1d7e
// http://benalman.com/about/license/
Packit 1c1d7e
// 
Packit 1c1d7e
// About: Examples
Packit 1c1d7e
// 
Packit 1c1d7e
// These working examples, complete with fully commented code, illustrate a few
Packit 1c1d7e
// ways in which this plugin can be used.
Packit 1c1d7e
// 
Packit 1c1d7e
// hashchange event - http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/
Packit 1c1d7e
// document.domain - http://benalman.com/code/projects/jquery-hashchange/examples/document_domain/
Packit 1c1d7e
// 
Packit 1c1d7e
// About: Support and Testing
Packit 1c1d7e
// 
Packit 1c1d7e
// Information about what version or versions of jQuery this plugin has been
Packit 1c1d7e
// tested with, what browsers it has been tested in, and where the unit tests
Packit 1c1d7e
// reside (so you can test it yourself).
Packit 1c1d7e
// 
Packit 1c1d7e
// jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2
Packit 1c1d7e
// Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5,
Packit 1c1d7e
//                   Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5.
Packit 1c1d7e
// Unit Tests      - http://benalman.com/code/projects/jquery-hashchange/unit/
Packit 1c1d7e
// 
Packit 1c1d7e
// About: Known issues
Packit 1c1d7e
// 
Packit 1c1d7e
// While this jQuery hashchange event implementation is quite stable and
Packit 1c1d7e
// robust, there are a few unfortunate browser bugs surrounding expected
Packit 1c1d7e
// hashchange event-based behaviors, independent of any JavaScript
Packit 1c1d7e
// window.onhashchange abstraction. See the following examples for more
Packit 1c1d7e
// information:
Packit 1c1d7e
// 
Packit 1c1d7e
// Chrome: Back Button - http://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/
Packit 1c1d7e
// Firefox: Remote XMLHttpRequest - http://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/
Packit 1c1d7e
// WebKit: Back Button in an Iframe - http://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/
Packit 1c1d7e
// Safari: Back Button from a different domain - http://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/
Packit 1c1d7e
// 
Packit 1c1d7e
// Also note that should a browser natively support the window.onhashchange 
Packit 1c1d7e
// event, but not report that it does, the fallback polling loop will be used.
Packit 1c1d7e
// 
Packit 1c1d7e
// About: Release History
Packit 1c1d7e
// 
Packit 1c1d7e
// 1.3   - (7/21/2010) Reorganized IE6/7 Iframe code to make it more
Packit 1c1d7e
//         "removable" for mobile-only development. Added IE6/7 document.title
Packit 1c1d7e
//         support. Attempted to make Iframe as hidden as possible by using
Packit 1c1d7e
//         techniques from http://www.paciellogroup.com/blog/?p=604. Added 
Packit 1c1d7e
//         support for the "shortcut" format $(window).hashchange( fn ) and
Packit 1c1d7e
//         $(window).hashchange() like jQuery provides for built-in events.
Packit 1c1d7e
//         Renamed jQuery.hashchangeDelay to <jQuery.fn.hashchange.delay> and
Packit 1c1d7e
//         lowered its default value to 50. Added <jQuery.fn.hashchange.domain>
Packit 1c1d7e
//         and <jQuery.fn.hashchange.src> properties plus document-domain.html
Packit 1c1d7e
//         file to address access denied issues when setting document.domain in
Packit 1c1d7e
//         IE6/7.
Packit 1c1d7e
// 1.2   - (2/11/2010) Fixed a bug where coming back to a page using this plugin
Packit 1c1d7e
//         from a page on another domain would cause an error in Safari 4. Also,
Packit 1c1d7e
//         IE6/7 Iframe is now inserted after the body (this actually works),
Packit 1c1d7e
//         which prevents the page from scrolling when the event is first bound.
Packit 1c1d7e
//         Event can also now be bound before DOM ready, but it won't be usable
Packit 1c1d7e
//         before then in IE6/7.
Packit 1c1d7e
// 1.1   - (1/21/2010) Incorporated document.documentMode test to fix IE8 bug
Packit 1c1d7e
//         where browser version is incorrectly reported as 8.0, despite
Packit 1c1d7e
//         inclusion of the X-UA-Compatible IE=EmulateIE7 meta tag.
Packit 1c1d7e
// 1.0   - (1/9/2010) Initial Release. Broke out the jQuery BBQ event.special
Packit 1c1d7e
//         window.onhashchange functionality into a separate plugin for users
Packit 1c1d7e
//         who want just the basic event & back button support, without all the
Packit 1c1d7e
//         extra awesomeness that BBQ provides. This plugin will be included as
Packit 1c1d7e
//         part of jQuery BBQ, but also be available separately.
Packit 1c1d7e
Packit 1c1d7e
(function($,window,undefined){
Packit 1c1d7e
  '$:nomunge'; // Used by YUI compressor.
Packit 1c1d7e
  
Packit 1c1d7e
  // Reused string.
Packit 1c1d7e
  var str_hashchange = 'hashchange',
Packit 1c1d7e
    
Packit 1c1d7e
    // Method / object references.
Packit 1c1d7e
    doc = document,
Packit 1c1d7e
    fake_onhashchange,
Packit 1c1d7e
    special = $.event.special,
Packit 1c1d7e
    
Packit 1c1d7e
    // Does the browser support window.onhashchange? Note that IE8 running in
Packit 1c1d7e
    // IE7 compatibility mode reports true for 'onhashchange' in window, even
Packit 1c1d7e
    // though the event isn't supported, so also test document.documentMode.
Packit 1c1d7e
    doc_mode = doc.documentMode,
Packit 1c1d7e
    supports_onhashchange = 'on' + str_hashchange in window && ( doc_mode === undefined || doc_mode > 7 );
Packit 1c1d7e
  
Packit 1c1d7e
  // Get location.hash (or what you'd expect location.hash to be) sans any
Packit 1c1d7e
  // leading #. Thanks for making this necessary, Firefox!
Packit 1c1d7e
  function get_fragment( url ) {
Packit 1c1d7e
    url = url || location.href;
Packit 1c1d7e
    return '#' + url.replace( /^[^#]*#?(.*)$/, '$1' );
Packit 1c1d7e
  };
Packit 1c1d7e
  
Packit 1c1d7e
  // Method: jQuery.fn.hashchange
Packit 1c1d7e
  // 
Packit 1c1d7e
  // Bind a handler to the window.onhashchange event or trigger all bound
Packit 1c1d7e
  // window.onhashchange event handlers. This behavior is consistent with
Packit 1c1d7e
  // jQuery's built-in event handlers.
Packit 1c1d7e
  // 
Packit 1c1d7e
  // Usage:
Packit 1c1d7e
  // 
Packit 1c1d7e
  // > jQuery(window).hashchange( [ handler ] );
Packit 1c1d7e
  // 
Packit 1c1d7e
  // Arguments:
Packit 1c1d7e
  // 
Packit 1c1d7e
  //  handler - (Function) Optional handler to be bound to the hashchange
Packit 1c1d7e
  //    event. This is a "shortcut" for the more verbose form:
Packit 1c1d7e
  //    jQuery(window).bind( 'hashchange', handler ). If handler is omitted,
Packit 1c1d7e
  //    all bound window.onhashchange event handlers will be triggered. This
Packit 1c1d7e
  //    is a shortcut for the more verbose
Packit 1c1d7e
  //    jQuery(window).trigger( 'hashchange' ). These forms are described in
Packit 1c1d7e
  //    the <hashchange event> section.
Packit 1c1d7e
  // 
Packit 1c1d7e
  // Returns:
Packit 1c1d7e
  // 
Packit 1c1d7e
  //  (jQuery) The initial jQuery collection of elements.
Packit 1c1d7e
  
Packit 1c1d7e
  // Allow the "shortcut" format $(elem).hashchange( fn ) for binding and
Packit 1c1d7e
  // $(elem).hashchange() for triggering, like jQuery does for built-in events.
Packit 1c1d7e
  $.fn[ str_hashchange ] = function( fn ) {
Packit 1c1d7e
    return fn ? this.bind( str_hashchange, fn ) : this.trigger( str_hashchange );
Packit 1c1d7e
  };
Packit 1c1d7e
  
Packit 1c1d7e
  // Property: jQuery.fn.hashchange.delay
Packit 1c1d7e
  // 
Packit 1c1d7e
  // The numeric interval (in milliseconds) at which the <hashchange event>
Packit 1c1d7e
  // polling loop executes. Defaults to 50.
Packit 1c1d7e
  
Packit 1c1d7e
  // Property: jQuery.fn.hashchange.domain
Packit 1c1d7e
  // 
Packit 1c1d7e
  // If you're setting document.domain in your JavaScript, and you want hash
Packit 1c1d7e
  // history to work in IE6/7, not only must this property be set, but you must
Packit 1c1d7e
  // also set document.domain BEFORE jQuery is loaded into the page. This
Packit 1c1d7e
  // property is only applicable if you are supporting IE6/7 (or IE8 operating
Packit 1c1d7e
  // in "IE7 compatibility" mode).
Packit 1c1d7e
  // 
Packit 1c1d7e
  // In addition, the <jQuery.fn.hashchange.src> property must be set to the
Packit 1c1d7e
  // path of the included "document-domain.html" file, which can be renamed or
Packit 1c1d7e
  // modified if necessary (note that the document.domain specified must be the
Packit 1c1d7e
  // same in both your main JavaScript as well as in this file).
Packit 1c1d7e
  // 
Packit 1c1d7e
  // Usage:
Packit 1c1d7e
  // 
Packit 1c1d7e
  // jQuery.fn.hashchange.domain = document.domain;
Packit 1c1d7e
  
Packit 1c1d7e
  // Property: jQuery.fn.hashchange.src
Packit 1c1d7e
  // 
Packit 1c1d7e
  // If, for some reason, you need to specify an Iframe src file (for example,
Packit 1c1d7e
  // when setting document.domain as in <jQuery.fn.hashchange.domain>), you can
Packit 1c1d7e
  // do so using this property. Note that when using this property, history
Packit 1c1d7e
  // won't be recorded in IE6/7 until the Iframe src file loads. This property
Packit 1c1d7e
  // is only applicable if you are supporting IE6/7 (or IE8 operating in "IE7
Packit 1c1d7e
  // compatibility" mode).
Packit 1c1d7e
  // 
Packit 1c1d7e
  // Usage:
Packit 1c1d7e
  // 
Packit 1c1d7e
  // jQuery.fn.hashchange.src = 'path/to/file.html';
Packit 1c1d7e
  
Packit 1c1d7e
  $.fn[ str_hashchange ].delay = 50;
Packit 1c1d7e
  /*
Packit 1c1d7e
  $.fn[ str_hashchange ].domain = null;
Packit 1c1d7e
  $.fn[ str_hashchange ].src = null;
Packit 1c1d7e
  */
Packit 1c1d7e
  
Packit 1c1d7e
  // Event: hashchange event
Packit 1c1d7e
  // 
Packit 1c1d7e
  // Fired when location.hash changes. In browsers that support it, the native
Packit 1c1d7e
  // HTML5 window.onhashchange event is used, otherwise a polling loop is
Packit 1c1d7e
  // initialized, running every <jQuery.fn.hashchange.delay> milliseconds to
Packit 1c1d7e
  // see if the hash has changed. In IE6/7 (and IE8 operating in "IE7
Packit 1c1d7e
  // compatibility" mode), a hidden Iframe is created to allow the back button
Packit 1c1d7e
  // and hash-based history to work.
Packit 1c1d7e
  // 
Packit 1c1d7e
  // Usage as described in <jQuery.fn.hashchange>:
Packit 1c1d7e
  // 
Packit 1c1d7e
  // > // Bind an event handler.
Packit 1c1d7e
  // > jQuery(window).hashchange( function(e) {
Packit 1c1d7e
  // >   var hash = location.hash;
Packit 1c1d7e
  // >   ...
Packit 1c1d7e
  // > });
Packit 1c1d7e
  // > 
Packit 1c1d7e
  // > // Manually trigger the event handler.
Packit 1c1d7e
  // > jQuery(window).hashchange();
Packit 1c1d7e
  // 
Packit 1c1d7e
  // A more verbose usage that allows for event namespacing:
Packit 1c1d7e
  // 
Packit 1c1d7e
  // > // Bind an event handler.
Packit 1c1d7e
  // > jQuery(window).bind( 'hashchange', function(e) {
Packit 1c1d7e
  // >   var hash = location.hash;
Packit 1c1d7e
  // >   ...
Packit 1c1d7e
  // > });
Packit 1c1d7e
  // > 
Packit 1c1d7e
  // > // Manually trigger the event handler.
Packit 1c1d7e
  // > jQuery(window).trigger( 'hashchange' );
Packit 1c1d7e
  // 
Packit 1c1d7e
  // Additional Notes:
Packit 1c1d7e
  // 
Packit 1c1d7e
  // * The polling loop and Iframe are not created until at least one handler
Packit 1c1d7e
  //   is actually bound to the 'hashchange' event.
Packit 1c1d7e
  // * If you need the bound handler(s) to execute immediately, in cases where
Packit 1c1d7e
  //   a location.hash exists on page load, via bookmark or page refresh for
Packit 1c1d7e
  //   example, use jQuery(window).hashchange() or the more verbose 
Packit 1c1d7e
  //   jQuery(window).trigger( 'hashchange' ).
Packit 1c1d7e
  // * The event can be bound before DOM ready, but since it won't be usable
Packit 1c1d7e
  //   before then in IE6/7 (due to the necessary Iframe), recommended usage is
Packit 1c1d7e
  //   to bind it inside a DOM ready handler.
Packit 1c1d7e
  
Packit 1c1d7e
  // Override existing $.event.special.hashchange methods (allowing this plugin
Packit 1c1d7e
  // to be defined after jQuery BBQ in BBQ's source code).
Packit 1c1d7e
  special[ str_hashchange ] = $.extend( special[ str_hashchange ], {
Packit 1c1d7e
    
Packit 1c1d7e
    // Called only when the first 'hashchange' event is bound to window.
Packit 1c1d7e
    setup: function() {
Packit 1c1d7e
      // If window.onhashchange is supported natively, there's nothing to do..
Packit 1c1d7e
      if ( supports_onhashchange ) { return false; }
Packit 1c1d7e
      
Packit 1c1d7e
      // Otherwise, we need to create our own. And we don't want to call this
Packit 1c1d7e
      // until the user binds to the event, just in case they never do, since it
Packit 1c1d7e
      // will create a polling loop and possibly even a hidden Iframe.
Packit 1c1d7e
      $( fake_onhashchange.start );
Packit 1c1d7e
    },
Packit 1c1d7e
    
Packit 1c1d7e
    // Called only when the last 'hashchange' event is unbound from window.
Packit 1c1d7e
    teardown: function() {
Packit 1c1d7e
      // If window.onhashchange is supported natively, there's nothing to do..
Packit 1c1d7e
      if ( supports_onhashchange ) { return false; }
Packit 1c1d7e
      
Packit 1c1d7e
      // Otherwise, we need to stop ours (if possible).
Packit 1c1d7e
      $( fake_onhashchange.stop );
Packit 1c1d7e
    }
Packit 1c1d7e
    
Packit 1c1d7e
  });
Packit 1c1d7e
  
Packit 1c1d7e
  // fake_onhashchange does all the work of triggering the window.onhashchange
Packit 1c1d7e
  // event for browsers that don't natively support it, including creating a
Packit 1c1d7e
  // polling loop to watch for hash changes and in IE 6/7 creating a hidden
Packit 1c1d7e
  // Iframe to enable back and forward.
Packit 1c1d7e
  fake_onhashchange = (function(){
Packit 1c1d7e
    var self = {},
Packit 1c1d7e
      timeout_id,
Packit 1c1d7e
      
Packit 1c1d7e
      // Remember the initial hash so it doesn't get triggered immediately.
Packit 1c1d7e
      last_hash = get_fragment(),
Packit 1c1d7e
      
Packit 1c1d7e
      fn_retval = function(val){ return val; },
Packit 1c1d7e
      history_set = fn_retval,
Packit 1c1d7e
      history_get = fn_retval;
Packit 1c1d7e
    
Packit 1c1d7e
    // Start the polling loop.
Packit 1c1d7e
    self.start = function() {
Packit 1c1d7e
      timeout_id || poll();
Packit 1c1d7e
    };
Packit 1c1d7e
    
Packit 1c1d7e
    // Stop the polling loop.
Packit 1c1d7e
    self.stop = function() {
Packit 1c1d7e
      timeout_id && clearTimeout( timeout_id );
Packit 1c1d7e
      timeout_id = undefined;
Packit 1c1d7e
    };
Packit 1c1d7e
    
Packit 1c1d7e
    // This polling loop checks every $.fn.hashchange.delay milliseconds to see
Packit 1c1d7e
    // if location.hash has changed, and triggers the 'hashchange' event on
Packit 1c1d7e
    // window when necessary.
Packit 1c1d7e
    function poll() {
Packit 1c1d7e
      var hash = get_fragment(),
Packit 1c1d7e
        history_hash = history_get( last_hash );
Packit 1c1d7e
      
Packit 1c1d7e
      if ( hash !== last_hash ) {
Packit 1c1d7e
        history_set( last_hash = hash, history_hash );
Packit 1c1d7e
        
Packit 1c1d7e
        $(window).trigger( str_hashchange );
Packit 1c1d7e
        
Packit 1c1d7e
      } else if ( history_hash !== last_hash ) {
Packit 1c1d7e
        location.href = location.href.replace( /#.*/, '' ) + history_hash;
Packit 1c1d7e
      }
Packit 1c1d7e
      
Packit 1c1d7e
      timeout_id = setTimeout( poll, $.fn[ str_hashchange ].delay );
Packit 1c1d7e
    };
Packit 1c1d7e
    
Packit 1c1d7e
    // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Packit 1c1d7e
    // vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv
Packit 1c1d7e
    // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Packit 1c1d7e
    $.browser.msie && !supports_onhashchange && (function(){
Packit 1c1d7e
      // Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8
Packit 1c1d7e
      // when running in "IE7 compatibility" mode.
Packit 1c1d7e
      
Packit 1c1d7e
      var iframe,
Packit 1c1d7e
        iframe_src;
Packit 1c1d7e
      
Packit 1c1d7e
      // When the event is bound and polling starts in IE 6/7, create a hidden
Packit 1c1d7e
      // Iframe for history handling.
Packit 1c1d7e
      self.start = function(){
Packit 1c1d7e
        if ( !iframe ) {
Packit 1c1d7e
          iframe_src = $.fn[ str_hashchange ].src;
Packit 1c1d7e
          iframe_src = iframe_src && iframe_src + get_fragment();
Packit 1c1d7e
          
Packit 1c1d7e
          // Create hidden Iframe. Attempt to make Iframe as hidden as possible
Packit 1c1d7e
          // by using techniques from http://www.paciellogroup.com/blog/?p=604.
Packit 1c1d7e
          iframe = $('<iframe tabindex="-1" title="empty"/>').hide()
Packit 1c1d7e
            
Packit 1c1d7e
            // When Iframe has completely loaded, initialize the history and
Packit 1c1d7e
            // start polling.
Packit 1c1d7e
            .one( 'load', function(){
Packit 1c1d7e
              iframe_src || history_set( get_fragment() );
Packit 1c1d7e
              poll();
Packit 1c1d7e
            })
Packit 1c1d7e
            
Packit 1c1d7e
            // Load Iframe src if specified, otherwise nothing.
Packit 1c1d7e
            .attr( 'src', iframe_src || 'javascript:0' )
Packit 1c1d7e
            
Packit 1c1d7e
            // Append Iframe after the end of the body to prevent unnecessary
Packit 1c1d7e
            // initial page scrolling (yes, this works).
Packit 1c1d7e
            .insertAfter( 'body' )[0].contentWindow;
Packit 1c1d7e
          
Packit 1c1d7e
          // Whenever `document.title` changes, update the Iframe's title to
Packit 1c1d7e
          // prettify the back/next history menu entries. Since IE sometimes
Packit 1c1d7e
          // errors with "Unspecified error" the very first time this is set
Packit 1c1d7e
          // (yes, very useful) wrap this with a try/catch block.
Packit 1c1d7e
          doc.onpropertychange = function(){
Packit 1c1d7e
            try {
Packit 1c1d7e
              if ( event.propertyName === 'title' ) {
Packit 1c1d7e
                iframe.document.title = doc.title;
Packit 1c1d7e
              }
Packit 1c1d7e
            } catch(e) {}
Packit 1c1d7e
          };
Packit 1c1d7e
          
Packit 1c1d7e
        }
Packit 1c1d7e
      };
Packit 1c1d7e
      
Packit 1c1d7e
      // Override the "stop" method since an IE6/7 Iframe was created. Even
Packit 1c1d7e
      // if there are no longer any bound event handlers, the polling loop
Packit 1c1d7e
      // is still necessary for back/next to work at all!
Packit 1c1d7e
      self.stop = fn_retval;
Packit 1c1d7e
      
Packit 1c1d7e
      // Get history by looking at the hidden Iframe's location.hash.
Packit 1c1d7e
      history_get = function() {
Packit 1c1d7e
        return get_fragment( iframe.location.href );
Packit 1c1d7e
      };
Packit 1c1d7e
      
Packit 1c1d7e
      // Set a new history item by opening and then closing the Iframe
Packit 1c1d7e
      // document, *then* setting its location.hash. If document.domain has
Packit 1c1d7e
      // been set, update that as well.
Packit 1c1d7e
      history_set = function( hash, history_hash ) {
Packit 1c1d7e
        var iframe_doc = iframe.document,
Packit 1c1d7e
          domain = $.fn[ str_hashchange ].domain;
Packit 1c1d7e
        
Packit 1c1d7e
        if ( hash !== history_hash ) {
Packit 1c1d7e
          // Update Iframe with any initial `document.title` that might be set.
Packit 1c1d7e
          iframe_doc.title = doc.title;
Packit 1c1d7e
          
Packit 1c1d7e
          // Opening the Iframe's document after it has been closed is what
Packit 1c1d7e
          // actually adds a history entry.
Packit 1c1d7e
          iframe_doc.open();
Packit 1c1d7e
          
Packit 1c1d7e
          // Set document.domain for the Iframe document as well, if necessary.
Packit 1c1d7e
          domain && iframe_doc.write( '<script>document.domain="' + domain + '"</script>' );
Packit 1c1d7e
          
Packit 1c1d7e
          iframe_doc.close();
Packit 1c1d7e
          
Packit 1c1d7e
          // Update the Iframe's hash, for great justice.
Packit 1c1d7e
          iframe.location.hash = hash;
Packit 1c1d7e
        }
Packit 1c1d7e
      };
Packit 1c1d7e
      
Packit 1c1d7e
    })();
Packit 1c1d7e
    // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Packit 1c1d7e
    // ^^^^^^^^^^^^^^^^^^^ REMOVE IF NOT SUPPORTING IE6/7/8 ^^^^^^^^^^^^^^^^^^^
Packit 1c1d7e
    // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Packit 1c1d7e
    
Packit 1c1d7e
    return self;
Packit 1c1d7e
  })();
Packit 1c1d7e
  
Packit 1c1d7e
})(jQuery,this);