jQuery mobile类库使用时加载导航历史的方法简介
网络编程 2021-07-04 21:03www.168986.cn编程入门
这篇文章主要介绍了jQuery mobile开发中加载导航历史的方法,jQuery mobile是jQuery针对移动设备开发的JavaScript库,需要的朋友可以参考下
jQuery.mobile.navigate( url [, data ] )
改变URL和跟踪历史。作品为浏览器和无历史新的API
- url是必须的参数。类型字符串
- data是可选的参数。类型对象。
更改哈希片段两次然后日志提供导航事件数据时,浏览器向后移动的历史
// Starting at http://example./ // Alter the URL: http://example./ => http://example./#foo $.mobile.navigate( "#foo", { info: "info about the #foo hash" }); // Alter the URL: http://example./#foo => http://example./#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./#bar => http://example./#foo window.history.back(); // From the `navigate` binding on the window, console output: // => "info about the #foo hash" // => "back" // => "http://example./#bar // => "#bar"
劫持一个链接点击使用导航方法,然后加载内容
// Starting at http://example./ // 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 aording 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" ) ); });
编程语言
- 宿迁百度关键词排名指南:实现精准营销的关键
- 四川SEO优化怎么做网络推广
- 立昂技术备案老域名收购:如何为您的业务赋能
- 安徽百度关键词seo贵不贵,一般需要多少钱
- 吉林百度快照排名怎么做电话营销
- 多伦新手做SEO怎么做
- 甘肃优化关键词排名推广怎么做论坛营销
- 沙雅SEO网站推广:提升您的在线可见性
- 四川SEO优化如何提升销售额和销售量
- 聂荣网站排名优化:提升网站可见性的全方位指
- 涞水SEO:提升地方企业在线可见性的策略
- 辽宁百度seo排名怎样做网站排名
- 临湘哪有关键词排名优化:提升网站可见度的关
- 黑龙江百度网站优化有没有优惠
- 凉城优化关键词排名推广:提升您的网络可见性
- 萝北整站优化:提升您网站流量和排名的全面指