Skip to content

Commit 269e0ed

Browse files
committed
Further modularized IE6/7 code for maximum ease-of-removal for mobile development. Also, slight minification tweaks.
1 parent 8da2c03 commit 269e0ed

File tree

8 files changed

+38
-35
lines changed

8 files changed

+38
-35
lines changed

README.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# jQuery hashchange event #
22
[http://benalman.com/projects/jquery-hashchange-plugin/](http://benalman.com/projects/jquery-hashchange-plugin/)
33

4-
Version: 1.3pre, Last updated: 7/5/2010
4+
Version: 1.3pre, Last updated: 7/6/2010
55

66
This jQuery plugin enables very basic bookmarkable #hash history via a cross-browser window.onhashchange event.
77

@@ -27,7 +27,7 @@ reside (so you can test it yourself).
2727
1.2.6, 1.3.2, 1.4.1, 1.4.2
2828

2929
### Browsers Tested ###
30-
Internet Explorer 6-8, Firefox 2-4, Safari 3-5, Chrome 3-5, Opera 9.6-10.5.
30+
Internet Explorer 6-8, Firefox 2-4, Chrome 3-5, Safari 3-5, Opera 9.6-10.60, iPhone 3.1, Android 2.1, BlackBerry 4.6-5.
3131

3232
### Unit Tests ###
3333
[http://benalman.com/code/projects/jquery-hashchange/unit/](http://benalman.com/code/projects/jquery-hashchange/unit/)
@@ -57,7 +57,7 @@ Safari: Back Button from a different domain
5757

5858
## Release History ##
5959

60-
1.3pre - (7/5/2010) Reorganized IE6/7 Iframe code to make it more "removable" for mobile development. Added jQuery.hashchangeDomain, jQuery.hashchangeIframeSrc properties and document-domain.html file to address access denied issues when setting document.domain in IE6/7. Note that when using jQuery.hashchangeIframeSrc, history won't be recorded in IE6/7 until the Iframe src file loads. Lowered the default jQuery.hashchangeDelay to 50 milliseconds. Added IE6/7 document.title support. Attempt to make Iframe as hidden as possible by using techniques from http://www.paciellogroup.com/blog/?p=604.
60+
1.3pre - (7/6/2010) Reorganized IE6/7 Iframe code to make it more "removable" for mobile development. Added jQuery.hashchangeDomain, jQuery.hashchangeIframeSrc properties and document-domain.html file to address access denied issues when setting document.domain in IE6/7. Note that when using jQuery.hashchangeIframeSrc, history won't be recorded in IE6/7 until the Iframe src file loads. Lowered the default jQuery.hashchangeDelay to 50 milliseconds. Added IE6/7 document.title support. Attempt to make Iframe as hidden as possible by using techniques from http://www.paciellogroup.com/blog/?p=604.
6161
1.2 - (2/11/2010) Fixed a bug where coming back to a page using this plugin from a page on another domain would cause an error in Safari 4. Also, IE6/7 Iframe is now inserted after the body (this actually works), which prevents the page from scrolling when the event is first bound. Event can also now be bound before DOM ready, but it won't be usable before then in IE6/7.
6262
1.1 - (1/21/2010) Incorporated document.documentMode test to fix IE8 bug where browser version is incorrectly reported as 8.0, despite inclusion of the X-UA-Compatible IE=EmulateIE7 meta tag.
6363
1.0 - (1/9/2010) Initial Release. Broke out the jQuery BBQ event.special window.onhashchange functionality into a separate plugin for users who want just the basic event & back button support, without all the extra awesomeness that BBQ provides. This plugin will be included as part of jQuery BBQ, but also be available separately.

docs/files/jquery-ba-hashchange-js.html

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

docs/index/Files.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<div id=Index><div class=IPageTitle>File Index</div><div class=INavigationBar>$#! &middot; 0-9 &middot; A &middot; B &middot; C &middot; D &middot; E &middot; F &middot; G &middot; H &middot; I &middot; <a href="#J">J</a> &middot; K &middot; L &middot; M &middot; N &middot; O &middot; P &middot; Q &middot; R &middot; S &middot; T &middot; U &middot; V &middot; W &middot; X &middot; Y &middot; Z</div><table border=0 cellspacing=0 cellpadding=0><tr><td class=IHeading id=IFirstHeading><a name="J"></a>J</td><td></td></tr><tr><td class=ISymbolPrefix id=IOnlySymbolPrefix>&nbsp;</td><td class=IEntry><a href="../files/jquery-ba-hashchange-js.html#jQuery_hashchange_event" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')" class=ISymbol>jQuery hashchange event</a></td></tr></table>
1515
<!--START_ND_TOOLTIPS-->
16-
<div class=CToolTip id="tt1"><div class=CFile><b>Version: 1.3pre, Last updated: 7/5/2010</b></div></div><!--END_ND_TOOLTIPS-->
16+
<div class=CToolTip id="tt1"><div class=CFile><b>Version: 1.3pre, Last updated: 7/6/2010</b></div></div><!--END_ND_TOOLTIPS-->
1717

1818
</div><!--Index-->
1919

docs/index/General.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
<!--START_ND_TOOLTIPS-->
24-
<div class=CToolTip id="tt6"><div class=CFile><b>Version: 1.3pre, Last updated: 7/5/2010</b></div></div><!--END_ND_TOOLTIPS-->
24+
<div class=CToolTip id="tt6"><div class=CFile><b>Version: 1.3pre, Last updated: 7/6/2010</b></div></div><!--END_ND_TOOLTIPS-->
2525

2626

2727
<!--START_ND_TOOLTIPS-->

docs/nd/Data/FileInfo.nd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
1.4
22
JavaScript
3-
/srv/projects/jquery-hashchange/jquery.ba-hashchange.js 1278369175 1 jQuery hashchange event
4-
/srv/projects/jquery-hashchange/jquery.ba-hashchange.min.js 1278369180 0 /srv/projects/jquery-hashchange/jquery.ba-hashchange.min.js
3+
/srv/projects/jquery-hashchange/jquery.ba-hashchange.js 1278468263 1 jQuery hashchange event
4+
/srv/projects/jquery-hashchange/jquery.ba-hashchange.min.js 1278468471 0 /srv/projects/jquery-hashchange/jquery.ba-hashchange.min.js

docs/nd/Data/SymbolTable.nd

0 Bytes
Binary file not shown.

jquery.ba-hashchange.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery hashchange event - v1.3pre - 7/5/2010
2+
* jQuery hashchange event - v1.3pre - 7/6/2010
33
* http://benalman.com/projects/jquery-hashchange-plugin/
44
*
55
* Copyright (c) 2010 "Cowboy" Ben Alman
@@ -9,7 +9,7 @@
99

1010
// Script: jQuery hashchange event
1111
//
12-
// *Version: 1.3pre, Last updated: 7/5/2010*
12+
// *Version: 1.3pre, Last updated: 7/6/2010*
1313
//
1414
// Project Home - http://benalman.com/projects/jquery-hashchange-plugin/
1515
// GitHub - http://github.com/cowboy/jquery-hashchange/
@@ -37,7 +37,8 @@
3737
// reside (so you can test it yourself).
3838
//
3939
// jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2
40-
// Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Safari 3-5, Chrome 3-5, Opera 9.6-10.5.
40+
// Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 3-5, Safari 3-5,
41+
// Opera 9.6-10.60, iPhone 3.1, Android 2.1, BlackBerry 4.6-5.
4142
// Unit Tests - http://benalman.com/code/projects/jquery-hashchange/unit/
4243
//
4344
// About: Known issues
@@ -54,7 +55,7 @@
5455
//
5556
// About: Release History
5657
//
57-
// 1.3pre - (7/5/2010) Reorganized IE6/7 Iframe code to make it more
58+
// 1.3pre - (7/6/2010) Reorganized IE6/7 Iframe code to make it more
5859
// "removable" for mobile development. Added <jQuery.hashchangeDomain>,
5960
// <jQuery.hashchangeIframeSrc> properties and document-domain.html
6061
// file to address access denied issues when setting document.domain in
@@ -85,17 +86,15 @@
8586
var str_hashchange = 'hashchange',
8687

8788
// Method / object references.
89+
doc = document,
8890
fake_onhashchange,
8991
jq_event_special = $.event.special,
9092

91-
// IE6/7 specifically need some special love when it comes to back-button
92-
// support, so let's do a little browser sniffing..
93-
browser = $.browser,
94-
mode = document.documentMode,
95-
is_old_ie = browser.msie && ( mode === undefined || mode < 8 ),
96-
97-
// Does the browser support window.onhashchange?
98-
supports_onhashchange = 'on' + str_hashchange in window && ( mode === undefined || mode > 7 );
93+
// Does the browser support window.onhashchange? Note that IE8 running in
94+
// IE7 compatibility mode reports true for 'onhashchange' in window, even
95+
// though the event isn't supported, so also test document.documentMode.
96+
doc_mode = doc.documentMode,
97+
supports_onhashchange = 'on' + str_hashchange in window && ( doc_mode === undefined || doc_mode > 7 );
9998

10099
// Get location.hash (or what you'd expect location.hash to be) sans any
101100
// leading #. Thanks for making this necessary, Firefox!
@@ -234,12 +233,16 @@
234233
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
235234
// vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7 vvvvvvvvvvvvvvvvvvv
236235
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
237-
//
238-
// In IE 6/7, create a hidden Iframe for history handling.
239-
is_old_ie && (function(){
240-
var iframe,
236+
(function(){
237+
var browser = $.browser,
238+
iframe,
241239
iframe_src;
242240

241+
// If browser isn't IE 6/7, abort!! ABORT!!!
242+
if ( !browser.msie || browser.version > 7 ) { return; }
243+
244+
// When the event is bound and polling starts in IE 6/7, create a hidden
245+
// Iframe for history handling.
243246
self.start = function(){
244247
if ( !iframe ) {
245248
iframe_src = $[ str_hashchange + 'IframeSrc' ];
@@ -267,10 +270,10 @@
267270
// prettify the back/next history menu entries. Since IE sometimes
268271
// errors with "Unspecified error" the very first time this is set
269272
// (yes, very useful) wrap this with a try/catch block.
270-
document.onpropertychange = function(){
273+
doc.onpropertychange = function(){
271274
try {
272275
if ( event.propertyName === 'title' ) {
273-
iframe.document.title = document.title;
276+
iframe.document.title = doc.title;
274277
}
275278
} catch(e) {}
276279
};
@@ -292,18 +295,18 @@
292295
// document, *then* setting its location.hash. If document.domain has
293296
// been set, update that as well.
294297
history_set = function( hash, history_hash ) {
295-
var doc = iframe.document,
298+
var iframe_doc = iframe.document,
296299
domain = $[ str_hashchange + 'Domain' ];
297300

298301
if ( hash !== history_hash ) {
299302
// Update Iframe with any initial `document.title` that might be set.
300-
doc.title = document.title;
303+
iframe_doc.title = doc.title;
301304

302305
// Opening the Iframe's document after it has been closed is what
303306
// actually adds a history entry.
304-
doc.open();
305-
domain && doc.write( '<script>document.domain="' + domain + '"</script>' );
306-
doc.close();
307+
iframe_doc.open();
308+
domain && iframe_doc.write( '<script>document.domain="' + domain + '"</script>' );
309+
iframe_doc.close();
307310

308311
// Update the Iframe's hash, for great justice.
309312
iframe.location.hash = hash;

jquery.ba-hashchange.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)