jQuery mobile類庫(kù)使用時(shí)加載導(dǎo)航歷史的方法簡(jiǎn)介
jQuery.mobile.navigate( url [, data ] )
改變URL和跟蹤歷史。作品為瀏覽器和無(wú)歷史新的API
- url:是必須的參數(shù)。類型:字符串
- data:是可選的參數(shù)。類型:對(duì)象。
更改哈希片段兩次然后日志提供導(dǎo)航事件數(shù)據(jù)時(shí),瀏覽器向后移動(dòng)的歷史
// Starting at http://example.com/ // Alter the URL: http://example.com/ => http://example.com/#foo $.mobile.navigate( "#foo", { info: "info about the #foo hash" }); // Alter the URL: http://example.com/#foo => http://example.com/#bar $.mobile.navigate( "#bar" ); // Bind to the navigate event $( window ).on( "navigate", function( event, data ) { console.log( data.state.info ); console.log( data.state.direction ) console.log( data.state.url ) console.log( data.state.hash ) }); // Alter the URL: http://example.com/#bar => http://example.com/#foo window.history.back(); // From the `navigate` binding on the window, console output: // => "info about the #foo hash" // => "back" // => "http://example.com/#bar // => "#bar"
劫持一個(gè)鏈接點(diǎn)擊使用導(dǎo)航方法,然后加載內(nèi)容
// Starting at http://example.com/ // Define a click binding for all anchors in the page $( "a" ).on( "click", function( event ) { // Prevent the usual navigation behavior event.preventDefault(); // Alter the url according to the anchor's href attribute, and // store the data-foo attribute information with the url $.mobile.navigate( this.attr( "href" ), { foo: this.attr( "data-foo" ) }); // Hypothetical content alteration based on the url. E.g, make // an ajax request for JSON data and render a template into the page. alterContent( this.attr( "href" ) ); });
相關(guān)文章
jQuery實(shí)現(xiàn)用方向鍵控制層的上下左右移動(dòng)
本文將會(huì)使用jquery實(shí)現(xiàn)以下功能:按下方向鍵時(shí),使層向相應(yīng)的方向平滑移動(dòng)20像素;四個(gè)方向鍵的鍵碼分別是37(左)、38(上)、39(右)和40(下),感興趣的朋友可以了解下2013-01-01jQuery EasyUi 驗(yàn)證功能實(shí)例解析
本文給大家分享jquery easyui驗(yàn)證功能的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下2017-01-01使用jQuery中的wrap()函數(shù)操作HTML元素的教程
wrap(),顧名思義,就是包裹的意思,就是在你所在器外層包裹一層?xùn)|西,接下來(lái)我們就詳細(xì)來(lái)看使用jQuery中的wrap()函數(shù)操作HTML元素的教程:2016-05-05基于jQuery實(shí)現(xiàn)點(diǎn)擊同時(shí)更改兩個(gè)iframe的網(wǎng)址
最近寫了兩個(gè)管理后臺(tái)的前端頁(yè)面,其中有一個(gè)管理后臺(tái),左側(cè)菜單導(dǎo)航和右側(cè)內(nèi)容頁(yè)是兩個(gè)iframe,需求是,點(diǎn)擊上面的主導(dǎo)航時(shí),左側(cè)iframe和右側(cè)iframe調(diào)用不同的鏈接.2010-07-07jQuery居中元素scrollleft計(jì)算方法示例
這篇文章主要介紹了jQuery居中元素scrollleft計(jì)算方法,結(jié)合實(shí)例形式分析了jQuery獲取及計(jì)算頁(yè)面滾動(dòng)元素的相關(guān)操作技巧,需要的朋友可以參考下2017-01-01jQuery實(shí)現(xiàn)平滑滾動(dòng)頁(yè)面到指定錨點(diǎn)鏈接的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)平滑滾動(dòng)頁(yè)面到指定錨點(diǎn)鏈接的方法,涉及jquery鼠標(biāo)事件及頁(yè)面滾動(dòng)的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-07-07基于jQuery架構(gòu)javascript基礎(chǔ)體系
jQuery畢竟還只是一個(gè)基礎(chǔ)的最底層的工具集,封裝元素選擇器,事件等等,基本上能滿足一般的需求,但要從整體的WEB的周度來(lái)看,為了提高javascript開(kāi)發(fā)的效率與可重用性,就需要有一個(gè)整體的布局2011-01-01寫得不錯(cuò)的jquery table鼠標(biāo)經(jīng)過(guò)變色代碼
鼠標(biāo)經(jīng)過(guò)table變色的效果,想必大家都有遇到過(guò)吧,其實(shí)實(shí)現(xiàn)并不難,在本文為大家詳細(xì)介紹下jquery是如何實(shí)現(xiàn)的,感興趣的朋友可以參看下2013-09-09