|
| 1 | +<?xml version="1.0"?> |
| 2 | +<entry name="hashtag" type="event" return="jQuery"> |
| 3 | + <title>.hashchange()</title> |
| 4 | + <desc>Enables bookmarkable #hash history.</desc> |
| 5 | + <longdesc> |
| 6 | + <p>The jQuery Mobile <code>.hashchange()</code> event handler enables very basic bookmarkable #hash history by providing a callback function bound to the window.onhashchange event. The onhashchange event fires when a window's hash changes.</p> |
| 7 | + <p>In browsers that support it, the native HTML5 window.onhashchange event is used. In IE6/7 (and IE8 operating in "IE7 compatibility" mode), a hidden Iframe is created to allow the back button and hash-based history to work.</p> |
| 8 | + <xi:include href="../includes/core-extension-desc.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/> |
| 9 | + </longdesc> |
| 10 | + <added>1.0</added> |
| 11 | + <signature> |
| 12 | + <argument name="callback" type="Function" optional="true"> |
| 13 | + <desc>A function to invoke after the onhashchange event is fired.</desc> |
| 14 | + </argument> |
| 15 | + </signature> |
| 16 | + <example> |
| 17 | + <desc>Click, and watch as the magic happens!</desc> |
| 18 | + <code><; |
| 32 | + }); |
| 33 | + }) |
| 34 | + // Since the event is only triggered when the hash changes, we need to trigger |
| 35 | + // the event now, to handle the hash the page may have loaded with. |
| 36 | + $(window).hashchange(); |
| 37 | + }); |
| 38 | + ]]></code> |
| 39 | + <html><![CDATA[ |
| 40 | + <style> |
| 41 | + #nav { |
| 42 | + font-size: 200%; |
| 43 | + } |
| 44 | +
|
| 45 | + #nav a { |
| 46 | + color: #777; |
| 47 | + border: 2px solid #777; |
| 48 | + background-color: #ccc; |
| 49 | + padding: 0.2em 0.6em; |
| 50 | + text-decoration: none; |
| 51 | + float: left; |
| 52 | + margin-right: 0.3em; |
| 53 | + } |
| 54 | +
|
| 55 | + #nav a:hover { |
| 56 | + color: #999; |
| 57 | + border-color: #999; |
| 58 | + background: #eee; |
| 59 | + } |
| 60 | +
|
| 61 | + #nav a.selected, |
| 62 | + #nav a.selected:hover { |
| 63 | + color: #0a0; |
| 64 | + border-color: #0a0; |
| 65 | + background: #afa; |
| 66 | + } |
| 67 | + </style> |
| 68 | +
|
| 69 | + <p id="nav"> |
| 70 | + <a href="#test1">test 1</a> |
| 71 | + <a href="#test2">test 2</a> |
| 72 | + <a href="#test3">test 3</a> |
| 73 | + <a href="#test4">test 4</a> |
| 74 | + </p> |
| 75 | + ]]></html> |
| 76 | + </example> |
| 77 | + <category slug="events"/> |
| 78 | +</entry> |
0 commit comments