├── LICENSE-GPL ├── LICENSE-MIT ├── README.markdown ├── docs ├── files │ └── jquery-ba-hashchange-js.html ├── index.html ├── index │ ├── Events.html │ ├── Files.html │ ├── Functions.html │ ├── General.html │ └── Properties.html ├── javascript │ ├── main.js │ └── searchdata.js ├── nd │ ├── Data │ │ ├── ClassHierarchy.nd │ │ ├── ConfigFileInfo.nd │ │ ├── FileInfo.nd │ │ ├── ImageFileInfo.nd │ │ ├── ImageReferenceTable.nd │ │ ├── IndexInfo.nd │ │ ├── PreviousMenuState.nd │ │ ├── PreviousSettings.nd │ │ └── SymbolTable.nd │ ├── Languages.txt │ ├── Menu.txt │ └── Topics.txt ├── search │ ├── EventsH.html │ ├── FilesJ.html │ ├── FunctionsH.html │ ├── GeneralD.html │ ├── GeneralE.html │ ├── GeneralF.html │ ├── GeneralH.html │ ├── GeneralJ.html │ ├── GeneralK.html │ ├── GeneralL.html │ ├── GeneralP.html │ ├── GeneralR.html │ ├── GeneralS.html │ ├── NoResults.html │ ├── PropertiesD.html │ └── PropertiesS.html └── styles │ ├── 1.css │ ├── 2.css │ └── main.css ├── document-domain.html ├── examples ├── bug-chrome-back-button │ └── index.php ├── bug-firefox-remote-xhr │ └── index.php ├── bug-safari-back-from-diff-domain │ └── index.php ├── bug-webkit-hash-iframe │ ├── child │ │ └── index.php │ └── index.php ├── config.php ├── document_domain │ └── index.php ├── donate.gif ├── hashchange │ └── index.php ├── index.css └── index.php ├── jquery.ba-hashchange.js ├── jquery.ba-hashchange.min.js ├── shared ├── SyntaxHighlighter │ ├── LGPLv3.txt │ ├── scripts │ │ ├── clipboard.swf │ │ ├── shBrushAS3.js │ │ ├── shBrushBash.js │ │ ├── shBrushCSharp.js │ │ ├── shBrushCpp.js │ │ ├── shBrushCss.js │ │ ├── shBrushDelphi.js │ │ ├── shBrushDiff.js │ │ ├── shBrushGroovy.js │ │ ├── shBrushJScript.js │ │ ├── shBrushJava.js │ │ ├── shBrushJavaFX.js │ │ ├── shBrushPerl.js │ │ ├── shBrushPhp.js │ │ ├── shBrushPlain.js │ │ ├── shBrushPowerShell.js │ │ ├── shBrushPython.js │ │ ├── shBrushRuby.js │ │ ├── shBrushScala.js │ │ ├── shBrushSql.js │ │ ├── shBrushVb.js │ │ ├── shBrushXml.js │ │ ├── shCore.js │ │ └── shLegacy.js │ ├── src │ │ ├── shCore.js │ │ └── shLegacy.js │ ├── styles │ │ ├── help.png │ │ ├── magnifier.png │ │ ├── page_white_code.png │ │ ├── page_white_copy.png │ │ ├── printer.png │ │ ├── shCore.css │ │ ├── shThemeDefault.css │ │ ├── shThemeDjango.css │ │ ├── shThemeEmacs.css │ │ ├── shThemeFadeToGrey.css │ │ ├── shThemeMidnight.css │ │ ├── shThemeRDark.css │ │ └── wrapping.png │ └── test.html ├── ba-debug.js ├── jquery-1.2.6.js ├── jquery-1.3.2.js ├── jquery-1.4.1.js ├── jquery-1.4.2.js ├── json_echo.php └── qunit.js └── unit ├── document-domain.html ├── ie7-compat.html ├── index.html ├── jquery-1.2.6.html ├── jquery-1.3.2.html ├── jquery-1.4.1.html ├── qunit.css └── unit.js /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 "Cowboy" Ben Alman 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | # jQuery hashchange event # 2 | [http://benalman.com/projects/jquery-hashchange-plugin/](http://benalman.com/projects/jquery-hashchange-plugin/) 3 | 4 | Version: 1.3, Last updated: 7/21/2010 5 | 6 | This jQuery plugin enables very basic bookmarkable #hash history via a cross-browser window.onhashchange event. 7 | 8 | Visit the [project page](http://benalman.com/projects/jquery-hashchange-plugin/) for more information and usage examples! 9 | 10 | 11 | ## Documentation ## 12 | [http://benalman.com/code/projects/jquery-hashchange/docs/](http://benalman.com/code/projects/jquery-hashchange/docs/) 13 | 14 | 15 | ## Examples ## 16 | These working examples, complete with fully commented code, illustrate a few 17 | ways in which this plugin can be used. 18 | 19 | [http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/](http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/) 20 | [http://benalman.com/code/projects/jquery-hashchange/examples/document_domain/](http://benalman.com/code/projects/jquery-hashchange/examples/document_domain/) 21 | 22 | ## Support and Testing ## 23 | Information about what version or versions of jQuery this plugin has been 24 | tested with, what browsers it has been tested in, and where the unit tests 25 | reside (so you can test it yourself). 26 | 27 | ### jQuery Versions ### 28 | 1.2.6, 1.3.2, 1.4.1, 1.4.2 29 | 30 | ### Browsers Tested ### 31 | Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5, Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5. 32 | 33 | ### Unit Tests ### 34 | [http://benalman.com/code/projects/jquery-hashchange/unit/](http://benalman.com/code/projects/jquery-hashchange/unit/) 35 | 36 | 37 | ## A more robust solution ## 38 | 39 | This plugin is, by design, very basic. If you want to add lot of extra utility around getting and setting the hash as a state, and parsing and merging fragment params, check out the [jQuery BBQ](http://benalman.com/projects/jquery-bbq-plugin/) plugin. It includes this plugin at its core, plus a whole lot more, and has thorough documentation and examples as well. You can't have too much of a good thing! 40 | 41 | 42 | ## Known issues ## 43 | 44 | While this jQuery hashchange event implementation is quite stable and robust, there are a few unfortunate browser bugs surrounding expected hashchange event-based behaviors, independent of any JavaScript window.onhashchange abstraction. See the following examples for more information: 45 | 46 | Chrome: Back Button 47 | [http://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/](http://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/) 48 | 49 | Firefox: Remote XMLHttpRequest 50 | [http://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/](http://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/) 51 | 52 | WebKit: Back Button in an Iframe 53 | [http://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/](http://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/) 54 | 55 | Safari: Back Button from a different domain 56 | [http://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/](http://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/) 57 | 58 | Also note that should a browser natively support the window.onhashchange 59 | event, but not report that it does, the fallback polling loop will be used. 60 | 61 | 62 | ## Release History ## 63 | 64 | 1.3 - (7/21/2010) Reorganized IE6/7 Iframe code to make it more "removable" for mobile-only development. Added IE6/7 document.title support. Attempted to make Iframe as hidden as possible by using techniques from http://www.paciellogroup.com/blog/?p=604. Added support for the "shortcut" format $(window).hashchange( fn ) and $(window).hashchange() like jQuery provides for built-in events. Renamed jQuery.hashchangeDelay to jQuery.fn.hashchange.delay and lowered its default value to 50. Added jQuery.fn.hashchange.domain and jQuery.fn.hashchange.src properties plus document-domain.html file to address access denied issues when setting document.domain in IE6/7. 65 | 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. 66 | 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. 67 | 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. 68 | 69 | 70 | ## License ## 71 | Copyright (c) 2010 "Cowboy" Ben Alman 72 | Dual licensed under the MIT and GPL licenses. 73 | [http://benalman.com/about/license/](http://benalman.com/about/license/) 74 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/index/Events.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Event Index 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Event Index
$#! · 0-9 · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z
H
 hashchange event
15 | 16 |
Fired when location.hash changes.
17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 |
Close
30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/index/Files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | File Index 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
File Index
$#! · 0-9 · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z
J
 jQuery hashchange event
15 | 16 |
Version: 1.3, Last updated: 7/21/2010
17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 |
Close
30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/index/Functions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Function Index 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Function Index
$#! · 0-9 · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z
H
 hashchange, jQuery.fn
15 | 16 |
Bind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 |
Close
30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/index/Properties.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Property Index 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Property Index
$#! · 0-9 · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z
D
 delay, jQuery.fn.hashchange
 domain, jQuery.fn.hashchange
S
 src, jQuery.fn.hashchange
15 | 16 |
The numeric interval (in milliseconds) at which the hashchange event polling loop executes.
If you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.
17 | 18 | 19 | 20 |
If, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.
21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 |
Close
34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/javascript/searchdata.js: -------------------------------------------------------------------------------- 1 | var indexSectionsWithContent = { 2 | "General": { 3 | "Symbols": false, 4 | "Numbers": false, 5 | "A": false, 6 | "B": false, 7 | "C": false, 8 | "D": false, 9 | "E": true, 10 | "F": false, 11 | "G": false, 12 | "H": true, 13 | "I": false, 14 | "J": true, 15 | "K": false, 16 | "L": true, 17 | "M": false, 18 | "N": false, 19 | "O": true, 20 | "P": true, 21 | "Q": false, 22 | "R": true, 23 | "S": true, 24 | "T": false, 25 | "U": false, 26 | "V": false, 27 | "W": false, 28 | "X": false, 29 | "Y": false, 30 | "Z": false 31 | }, 32 | "Functions": { 33 | "Symbols": false, 34 | "Numbers": false, 35 | "A": false, 36 | "B": false, 37 | "C": false, 38 | "D": false, 39 | "E": false, 40 | "F": false, 41 | "G": false, 42 | "H": true, 43 | "I": false, 44 | "J": false, 45 | "K": false, 46 | "L": false, 47 | "M": false, 48 | "N": false, 49 | "O": false, 50 | "P": false, 51 | "Q": false, 52 | "R": false, 53 | "S": false, 54 | "T": false, 55 | "U": false, 56 | "V": false, 57 | "W": false, 58 | "X": false, 59 | "Y": false, 60 | "Z": false 61 | }, 62 | "Files": { 63 | "Symbols": false, 64 | "Numbers": false, 65 | "A": false, 66 | "B": false, 67 | "C": false, 68 | "D": false, 69 | "E": false, 70 | "F": false, 71 | "G": false, 72 | "H": false, 73 | "I": false, 74 | "J": true, 75 | "K": false, 76 | "L": false, 77 | "M": false, 78 | "N": false, 79 | "O": false, 80 | "P": false, 81 | "Q": false, 82 | "R": false, 83 | "S": false, 84 | "T": false, 85 | "U": false, 86 | "V": false, 87 | "W": false, 88 | "X": false, 89 | "Y": false, 90 | "Z": false 91 | }, 92 | "Events": { 93 | "Symbols": false, 94 | "Numbers": false, 95 | "A": false, 96 | "B": false, 97 | "C": false, 98 | "D": false, 99 | "E": false, 100 | "F": false, 101 | "G": false, 102 | "H": true, 103 | "I": false, 104 | "J": false, 105 | "K": false, 106 | "L": false, 107 | "M": false, 108 | "N": false, 109 | "O": false, 110 | "P": false, 111 | "Q": false, 112 | "R": false, 113 | "S": false, 114 | "T": false, 115 | "U": false, 116 | "V": false, 117 | "W": false, 118 | "X": false, 119 | "Y": false, 120 | "Z": false 121 | }, 122 | "Properties": { 123 | "Symbols": false, 124 | "Numbers": false, 125 | "A": false, 126 | "B": false, 127 | "C": false, 128 | "D": true, 129 | "E": false, 130 | "F": false, 131 | "G": false, 132 | "H": false, 133 | "I": false, 134 | "J": false, 135 | "K": false, 136 | "L": false, 137 | "M": false, 138 | "N": false, 139 | "O": false, 140 | "P": false, 141 | "Q": false, 142 | "R": false, 143 | "S": true, 144 | "T": false, 145 | "U": false, 146 | "V": false, 147 | "W": false, 148 | "X": false, 149 | "Y": false, 150 | "Z": false 151 | } 152 | } -------------------------------------------------------------------------------- /docs/nd/Data/ClassHierarchy.nd: -------------------------------------------------------------------------------- 1 | ( -------------------------------------------------------------------------------- /docs/nd/Data/ConfigFileInfo.nd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cowboy/jquery-hashchange/0310f3847f9010faefa0b6abfcf56e8103096192/docs/nd/Data/ConfigFileInfo.nd -------------------------------------------------------------------------------- /docs/nd/Data/FileInfo.nd: -------------------------------------------------------------------------------- 1 | 1.4 2 | JavaScript 3 | /srv/projects/jquery-hashchange-beta/jquery.ba-hashchange.min.js 1279744078 0 /srv/projects/jquery-hashchange-beta/jquery.ba-hashchange.min.js 4 | /srv/projects/jquery-hashchange-beta/jquery.ba-hashchange.js 1279744067 1 jQuery hashchange event 5 | -------------------------------------------------------------------------------- /docs/nd/Data/ImageFileInfo.nd: -------------------------------------------------------------------------------- 1 | ( -------------------------------------------------------------------------------- /docs/nd/Data/ImageReferenceTable.nd: -------------------------------------------------------------------------------- 1 | ( -------------------------------------------------------------------------------- /docs/nd/Data/IndexInfo.nd: -------------------------------------------------------------------------------- 1 | (GeneralFunctionFileEventProperty -------------------------------------------------------------------------------- /docs/nd/Data/PreviousMenuState.nd: -------------------------------------------------------------------------------- 1 | (jQuery hashchange event 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/FilesJ.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/FunctionsH.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
hashchange, jQuery.fn
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralD.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
delay, jQuery.fn.hashchange
domain, jQuery.fn.hashchange
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralE.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralF.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralH.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
hashchange, jQuery.fn
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralJ.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralK.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralL.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralP.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralR.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/GeneralS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
src, jQuery.fn.hashchange
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/NoResults.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
No Matches
-------------------------------------------------------------------------------- /docs/search/PropertiesD.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
delay, jQuery.fn.hashchange
domain, jQuery.fn.hashchange
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/search/PropertiesS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Loading...
src, jQuery.fn.hashchange
Searching...
No Matches
-------------------------------------------------------------------------------- /docs/styles/2.css: -------------------------------------------------------------------------------- 1 | /* 2 | bg: #FDEBDC 3 | bg1: #FFD6AF 4 | bg2: #FFAB59 5 | orange: #FF7F00 6 | brown: #913D00 7 | lt. brown: #C4884F 8 | */ 9 | 10 | .IndexPage #Index { 11 | margin-left: 31ex !important; 12 | } 13 | 14 | #MSelected { 15 | -webkit-border-top-right-radius: 10px; 16 | -webkit-border-bottom-right-radius: 10px; 17 | } 18 | 19 | .MGroup #MSelected { 20 | -webkit-border-top-left-radius: 10px; 21 | -webkit-border-bottom-left-radius: 10px; 22 | } 23 | 24 | .Safari #MSelected { 25 | border-width: 1px; 26 | border-left-width: 0; 27 | } 28 | 29 | .Safari .MGroup #MSelected { 30 | border-left-width: 1px; 31 | } 32 | 33 | .SBorder { 34 | -webkit-border-radius: 20px; 35 | } 36 | 37 | 38 | body { 39 | font-size: 0.75em; 40 | line-height: 1.6em; 41 | font-family: Arial, sans-serif; 42 | } 43 | 44 | a:link, a:visited { 45 | color: #913D00; 46 | text-decoration: underline; 47 | } 48 | 49 | a:hover { 50 | color: #FF7F00; 51 | } 52 | 53 | p { 54 | margin-left: 5ex; 55 | text-indent: 0; 56 | margin-bottom: 0.6em; 57 | } 58 | 59 | .Summary a:link, .Summary a:visited { 60 | text-decoration: none; 61 | } 62 | 63 | .CClass .CTitle, .CInterface .CTitle, .CDatabase .CTitle, .CDatabaseTable .CTitle, .CSection .CTitle, 64 | #MainTopic .CTitle, 65 | .STitle { 66 | text-transform: uppercase; 67 | font-family: "Gill Sans", "Gill Sans MT", Arial, Helvetica, sans-serif; 68 | } 69 | 70 | .CClass .CTitle, .CInterface .CTitle, .CDatabase .CTitle, .CDatabaseTable .CTitle, .CSection .CTitle, 71 | .IPageTitle, 72 | #MainTopic .CTitle { 73 | color: #913D00; 74 | font-size: 22px; 75 | font-weight: 400; 76 | 77 | background: #FDEBDC; 78 | border: none; 79 | } 80 | 81 | .CClass .CTitle, .CInterface .CTitle, .CDatabase .CTitle, .CDatabaseTable .CTitle, .CSection .CTitle { 82 | border-top: 2px solid #913D00; 83 | } 84 | 85 | .CGroup .CTitle { 86 | color: #913D00; 87 | font-family: "Gill Sans", "Gill Sans MT", Arial, Helvetica, sans-serif; 88 | font-weight: 700; 89 | font-size: 130%; 90 | font-variant: none; 91 | border-bottom: 2px solid #913D00; 92 | } 93 | 94 | .CTitle { 95 | border-color: #C4884F; 96 | line-height: 1.2em; 97 | } 98 | 99 | .ContentPage #Content { 100 | background: #FDEBDC; 101 | } 102 | 103 | .STitle { 104 | color: #FF7F00; 105 | font-size: 140%; 106 | font-weight: 700; 107 | margin: 1.2em 0 0.3em; 108 | } 109 | 110 | .CBody pre { 111 | margin-left: 5ex; 112 | } 113 | 114 | .CBody pre, 115 | .CDLEntry { 116 | color: #913D00; 117 | font-family: Monaco, "Courier New", Courier, monospace; 118 | font-size: 9pt; 119 | } 120 | 121 | .SBorder { 122 | background-color: #fff; 123 | border: 1px solid #913D00; 124 | padding: 15px; 125 | } 126 | 127 | .SMarked { 128 | background-color: #eee; 129 | } 130 | 131 | .ContentPage, .IndexPage, .FramedMenuPage { 132 | background-color: #FFAB59; 133 | } 134 | 135 | .MEntry a:link, .MEntry a:hover, .MEntry a:visited, 136 | .MGroup a:link, .MGroup a:hover, .MGroup a:visited { 137 | color: #000; 138 | } 139 | 140 | #MSearchField { 141 | color: #913D00; 142 | background: #FDEBDC; 143 | } 144 | 145 | #Footer a:link, #Footer a:hover, #Footer a:visited { 146 | color: #913D00; 147 | } 148 | 149 | .INavigationBar { 150 | background: #FFD6AF; 151 | border-top: 1px solid #000; 152 | border-bottom: 1px solid #000; 153 | } 154 | 155 | #MSelected { 156 | color: #913D00; 157 | border-color: #913D00; 158 | } 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /docs/styles/main.css: -------------------------------------------------------------------------------- 1 | @import URL("1.css"); 2 | @import URL("2.css"); 3 | -------------------------------------------------------------------------------- /document-domain.html: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /examples/bug-chrome-back-button/index.php: -------------------------------------------------------------------------------- 1 | 15 | Read more about the issue here! 16 | 26 | 27 | var delay = 250; 28 | 29 | // Set the browser title. 30 | function set_title( i ) { 31 | document.title = document.title.replace( /\s*\d*$/, '' ) + ' ' + i; 32 | } 33 | 34 | // Add new history entries by changing window.location.hash, in an 35 | // asynchronous loop. 36 | function add_history_entries( start, end ) { 37 | (function loopy(){ 38 | window.location.hash = '#' + start; 39 | set_title( start ); 40 | ++start <= end && setTimeout( loopy, delay ); 41 | })(); 42 | }; 43 | 44 | // Go back in the history, in an asynchronous loop. 45 | function go_back( i ) { 46 | (function loopy(){ 47 | window.history.go(-1); 48 | --i && setTimeout( loopy, delay ); 49 | })(); 50 | }; 51 | 52 | // Some window.onhashchange stuff. Not really important here. 53 | function handler() { 54 | var i = window.location.hash.replace( /^#/, '' ); 55 | set_title( i ); 56 | }; 57 | 58 | if ( window.addEventListener ) { 59 | window.addEventListener( 'hashchange', handler, false ); 60 | } else if ( window.attachEvent ) { 61 | window.attachEvent( 'onhashchange', handler ); 62 | } 63 | 64 | 74 | 86 | 102 | 112 | 113 | 114 |

First, open this page in a new window or tab, to clear any current window or tab history. Make your window wide enough so that you can see the full URL in the address bar, with some extra space left over.

115 | 116 |

117 | Add ten history entries 118 |

119 | 120 | 126 | 127 |

128 | Go back 10 times 129 |

130 | 131 | 136 | 137 |

Notes

138 | 139 | 144 | 145 |

The code

146 | 147 |
148 | 
149 | 
150 | 151 | -------------------------------------------------------------------------------- /examples/bug-safari-back-from-diff-domain/index.php: -------------------------------------------------------------------------------- 1 | 15 | 16 | 26 | 27 | (function(window){ 28 | 29 | // A convenient shortcut. 30 | var win_loc = window.location, 31 | loc = location, 32 | state; 33 | 34 | (function loopy(){ 35 | console.log([ 36 | 'win_loc.href: ' + typeof win_loc.href, 37 | 'loc.href: ' + typeof loc.href, 38 | 'location.href: ' + typeof location.href, 39 | 'window.location.href: ' + typeof window.location.href 40 | ].join(', ')); 41 | timeout_id = setTimeout( loopy, 1000 ); 42 | })(); 43 | 44 | })(this); 45 | 46 | 56 | 68 | 95 | 105 | 106 | 107 |

108 | 1 109 | Open this page in Safari 4. 110 |

111 | 112 |

113 | 2 114 | Open the debugging Error Console (cmd-opt-C) 115 |

116 | 117 |

118 | 3 119 | Notice that win_loc.href: string, loc.href: string, location.href: string, window.location.href: string is getting printed to the console. 120 | This is expected. 121 |

122 | 123 |

124 | 4 125 | Navigate to a page on a different domain, like Google or GitHub. 126 |

127 | 128 |

129 | 5 130 | Press the back button. 131 |

132 | 133 |

134 | 6 135 | Notice that win_loc.href: undefined, loc.href: undefined, location.href: string, window.location.href: string is getting printed to the console. 136 | What's up with those undefined, Safari? 137 |

138 | 139 |

Tested in Safari Version 4.0.4 (5531.21.10) / WebKit nightly r54415. 140 | Submitted to WebKit Bugzilla as Bug 34679.

141 | 142 |

The code

143 | 144 |
145 | 
146 | 
147 | 148 | -------------------------------------------------------------------------------- /examples/bug-webkit-hash-iframe/child/index.php: -------------------------------------------------------------------------------- 1 | 16 | $(function(){ 17 | 18 | // Show the current location.hash. 19 | setInterval(function(){ $('#status').text( location.hash ); }, 100); 20 | 21 | }); 22 | 32 | 62 | 97 | 107 |

This page is part of a full example. If you didn't see a "step 1", click here to reset!

108 | 109 |

110 | 2 111 | Click these links to change the Iframe location.hash: 112 | #middle and 113 | #end. 114 |

115 |

116 | The location.hash should go from #begin → #middle → #end as you click the 117 | links above. 118 |

119 | 120 |

The current Iframe location.hash is:

121 | 122 |

123 | Now, in most modern browsers (not IE6 or 7), in an Iframe or not, each hash change 124 | creates a new history entry, so that the back button becomes enabled and you 125 | can press it to return to a previous entry. 126 |

127 | 128 |

129 | 3 130 | After clicking #middle and #end, press the back button twice. 131 |

132 |

133 | The location.hash should go from #end → #middle → #begin as you press the 134 | back button 135 |

136 | 137 |

138 | When the #middle or #end links are clicked, and the location.hash is changed, the back button 139 | should be enabled. In Firefox, IE8 and Opera this works as expected. In Safari and 140 | Chrome, in an Iframe, the back button stays disabled.. and in the latest WebKit 141 | nightly (r51669), the back button is enabled, but only partially. 142 |

143 |

144 | For whatever reason, when the location.hash is changed inside an Iframe in Safari 145 | or Chrome, no new history entries are created (and the back button stays disabled). 146 | In the latest WebKit nightly, new history entries are created, but not for the initial 147 | location.hash. Meaning you can go back, but never to #begin. 148 |

149 | 150 |

151 | 4 152 | Click here to load this page in the "top" and 153 | you'll see that everything works as-expected. Repeat steps 2 and 3 there, and you'll 154 | see that the location.hash goes from #begin → #middle → #end → #middle → #begin. When 155 | you're done, press the back button again to return to the "in an Iframe" page. 156 |

157 | 158 |

159 | 5 160 | Now that you've returned to the "in an Iframe" page, repeat steps 2 and 3 a final time.. 161 | and see that the history now works! Well, almost works, because you still can't 162 | get to the initial #begin location.hash in Safari, Chrome, or the WebKit nightly. 163 |

164 | 165 |

What's up with that, WebKit?

166 | 167 |

The code

168 | 169 |
170 | 
171 | 
172 | 173 | 184 | -------------------------------------------------------------------------------- /examples/bug-webkit-hash-iframe/index.php: -------------------------------------------------------------------------------- 1 | 15 | Read more about the issue here! 16 | 26 | 33 | 60 | 70 | 71 | 72 |

73 | 1 74 | First, open this page in a brand new window (right click this link, 75 | and select "open link in new window" if necessary) so that there is no browser 76 | history, and the back button is disabled (if the back button is clickable, 77 | it will complicate the example). 78 |

79 | 80 |

Tested in Safari Version 4.0.4 (5531.21.10) / Chrome 3.0.195.33 / WebKit nightly r51669. 81 | Submitted to WebKit Bugzilla as Bug 32156.

82 | 83 |

The Iframe

84 | 85 |
86 | 87 |
88 | 89 | 100 | -------------------------------------------------------------------------------- /examples/config.php: -------------------------------------------------------------------------------- 1 | 8 | Project Home, 9 | Documentation, 10 | Source 11 | 23 | -------------------------------------------------------------------------------- /examples/document_domain/index.php: -------------------------------------------------------------------------------- 1 | 15 | $(function(){ 16 | 17 | // These two properties, set after jQuery and the hashchange event plugin are 18 | // loaded, only need to be used when document.domain is set (to fix the "access 19 | // denied" error in IE6/7). 20 | $.fn.hashchange.src = '../../document-domain.html'; 21 | $.fn.hashchange.domain = document.domain; 22 | 23 | // Bind an event to window.onhashchange that, when the hash changes, gets the 24 | // hash and adds the class "selected" to any matching nav link. 25 | $(window).hashchange( function(){ 26 | var hash = location.hash; 27 | 28 | // Set the page title based on the hash. 29 | document.title = 'The hash is ' + ( hash.replace( /^#/, '' ) || 'blank' ) + '.'; 30 | 31 | // Iterate over all nav links, setting the "selected" class as-appropriate. 32 | $('#nav a').each(function(){ 33 | var that = $(this); 34 | that[ that.attr( 'href' ) === hash ? 'addClass' : 'removeClass' ]( 'selected' ); 35 | }); 36 | }) 37 | 38 | // Since the event is only triggered when the hash changes, we need to trigger 39 | // the event now, to handle the hash the page may have loaded with. 40 | $(window).hashchange(); 41 | 42 | }); 43 | 53 | 57 | 63 | 64 | 76 | 119 | 129 | 130 | 131 |

132 | jQuery hashchange event enables very basic bookmarkable #hash history via a cross-browser window.onhashchange event. This example is exactly like the basic hashchange event example except that document.domain is set, and the example code has been modifed accordingly. 133 |

134 | 135 |

Click, and watch as the magic happens!

136 | 137 | 143 | 144 |
145 | 146 |

147 | Note that there is absolutely no JavaScript attached to the click event of these links. All they do is set the location.hash via href, and the callback bound to the window.onhashchange event does the rest. Once you've clicked one or more of these links, fool around with your browser's back and next buttons. 148 |

149 | 150 |

The code

151 | 152 |
153 | 
154 | 
155 | 156 |

That's it!

157 | 158 |

159 | This plugin is, by design, very basic. If you want to add lot of extra utility around getting and setting the hash as a state, and parsing and merging fragment params, check out the jQuery BBQ plugin. It includes this plugin at its core, plus a whole lot more, and has thorough documentation and examples as well. You can't have too much of a good thing! 160 |

161 | 162 | -------------------------------------------------------------------------------- /examples/donate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cowboy/jquery-hashchange/0310f3847f9010faefa0b6abfcf56e8103096192/examples/donate.gif -------------------------------------------------------------------------------- /examples/hashchange/index.php: -------------------------------------------------------------------------------- 1 | 15 | $(function(){ 16 | 17 | // Bind an event to window.onhashchange that, when the hash changes, gets the 18 | // hash and adds the class "selected" to any matching nav link. 19 | $(window).hashchange( function(){ 20 | var hash = location.hash; 21 | 22 | // Set the page title based on the hash. 23 | document.title = 'The hash is ' + ( hash.replace( /^#/, '' ) || 'blank' ) + '.'; 24 | 25 | // Iterate over all nav links, setting the "selected" class as-appropriate. 26 | $('#nav a').each(function(){ 27 | var that = $(this); 28 | that[ that.attr( 'href' ) === hash ? 'addClass' : 'removeClass' ]( 'selected' ); 29 | }); 30 | }) 31 | 32 | // Since the event is only triggered when the hash changes, we need to trigger 33 | // the event now, to handle the hash the page may have loaded with. 34 | $(window).hashchange(); 35 | 36 | }); 37 | 47 | 48 | 60 | 103 | 113 | 114 | 115 |

116 | jQuery hashchange event enables very basic bookmarkable #hash history via a cross-browser window.onhashchange event. 117 |

118 | 119 |

Click, and watch as the magic happens!

120 | 121 | 127 | 128 |
129 | 130 |

131 | Note that there is absolutely no JavaScript attached to the click event of these links. All they do is set the location.hash via href, and the callback bound to the window.onhashchange event does the rest. Once you've clicked one or more of these links, fool around with your browser's back and next buttons. 132 |

133 | 134 |

The code

135 | 136 |
137 | 
138 | 
139 | 140 |

That's it!

141 | 142 |

143 | This plugin is, by design, very basic. If you want to add lot of extra utility around getting and setting the hash as a state, and parsing and merging fragment params, check out the jQuery BBQ plugin. It includes this plugin at its core, plus a whole lot more, and has thorough documentation and examples as well. You can't have too much of a good thing! 144 |

145 | 146 | -------------------------------------------------------------------------------- /examples/index.php: -------------------------------------------------------------------------------- 1 | 13 | 23 | 31 | 32 | 33 | 34 | Ben Alman » <?= $shell['title1'] ?><? if ( $shell['title2'] ) { print ' » ' . $shell['title2']; } ?><? if ( $shell['title3'] ) { print ' » ' . $shell['title3']; } ?> 35 | 36 | 37 | 38 | 39 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 | 87 |
88 | 89 |
90 | 98 |
99 | 100 | 101 | $title
"; 120 | } 121 | } 122 | 123 | $base = ''; 124 | draw_shell(); 125 | } 126 | 127 | ?> 128 | -------------------------------------------------------------------------------- /jquery.ba-hashchange.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery hashchange event - v1.3 - 7/21/2010 3 | * http://benalman.com/projects/jquery-hashchange-plugin/ 4 | * 5 | * Copyright (c) 2010 "Cowboy" Ben Alman 6 | * Dual licensed under the MIT and GPL licenses. 7 | * http://benalman.com/about/license/ 8 | */ 9 | (function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('