最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

jQuerymobile类库使用时加载导航历史的方法

来源:懂视网 责编:小采 时间:2020-11-27 19:34:29
文档

jQuerymobile类库使用时加载导航历史的方法

jQuerymobile类库使用时加载导航历史的方法:这篇文章主要介绍了jQuery mobile开发中加载导航历史的方法,jQuery mobile是jQuery针对移动设备开发的JavaScript库,需要的朋友可以参考下jQuery.mobile.navigate( url [, data ] )改变URL和跟踪历史。作品为浏览器和无历史新的APIurl:是必须的
推荐度:
导读jQuerymobile类库使用时加载导航历史的方法:这篇文章主要介绍了jQuery mobile开发中加载导航历史的方法,jQuery mobile是jQuery针对移动设备开发的JavaScript库,需要的朋友可以参考下jQuery.mobile.navigate( url [, data ] )改变URL和跟踪历史。作品为浏览器和无历史新的APIurl:是必须的

这篇文章主要介绍了jQuery mobile开发中加载导航历史的方法,jQuery mobile是jQuery针对移动设备开发的JavaScript库,需要的朋友可以参考下

jQuery.mobile.navigate( url [, data ] )

改变URL和跟踪历史。作品为浏览器和无历史新的API

  • url:是必须的参数。类型:字符串

  • data:是可选的参数。类型:对象。

  • 更改哈希片段两次然后日志提供导航事件数据时,浏览器向后移动的历史

    // 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"

    劫持一个链接点击使用导航方法,然后加载内容

    // 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" ) );
    });

    文档

    jQuerymobile类库使用时加载导航历史的方法

    jQuerymobile类库使用时加载导航历史的方法:这篇文章主要介绍了jQuery mobile开发中加载导航历史的方法,jQuery mobile是jQuery针对移动设备开发的JavaScript库,需要的朋友可以参考下jQuery.mobile.navigate( url [, data ] )改变URL和跟踪历史。作品为浏览器和无历史新的APIurl:是必须的
    推荐度:
    标签: 历史 加载 方法
    • 热门焦点

    最新推荐

    猜你喜欢

    热门推荐

    专题
    Top