• window.location.hash 页面跳转,精确定位,实例展示:


    window.location.hash 页面跳转,精确定位,实例展示:
    (1)、index.phtml,页面用于传参

    <script id="bb_list_template" type="text/x-dot-template">
    <a title="点击查看宝贝详情" href="<?php echo APP_WEB_INDEX_ROOT?>/item/itemdetail<?php echo HTML_TYPE;?>?qntag=1#iid=<%=it.num_iid%>&&state=<%=it.status%>&&page=<%=it.page%>" id="title_<%=it.num_iid%>">
    <%=it.title%>
    </a>
    </script>


    (2)、index.js,用于获取参数
    /**
    *window.location.hash 定义和用法
    *location是javascript里边管理地址栏的内置对象.
    *比如location.href就管理页面的url,用location.href=url就可以直接将页面重定向url。
    *而location.hash则可以用来获取或设置页面的标签值。比如http://domain/#admin的location.hash="#admin"。
    *
    *substr 定义和用法
    *substr() 方法可在字符串中抽取从 start 下标开始的指定数目的字符。
    *语法 stringObject.substr(start,length)
    *start 必需。要抽取的子串的起始下标。必须是数值。如果是负数,那么该参数声明从字符串的尾部开始算起的位置。
    *也就是说,-1 指字符串中最后一个字符,-2 指倒数第二个字符,以此类推。
    *length 可选。子串中的字符数。必须是数值。如果省略了该参数,那么返回从 stringObject 的开始位置到结尾的字串。
    */

    var shash = window.location.hash.substr(1);
    var params = shash.split('&');
    var map = new HashMap();
    for (var i in params) {
    var p = params[i].split("=");
    if (p.length == 2) {
    map.put(p[0], p[1]);
    }
    }
    num_iid = map.get('iid');
    detailstate = map.get('state');
    if(detailstate =='chuc' || detailstate == 'chus' || detailstate == 'cangk' || detailstate == 'shouw'){
    $('#deatailback').show();
    }
    page = map.get('page');

    (3)、返回按钮用于定位

    <a class="sui-btn btn-bordered btn-primary" style="display:none()" id="deatailback" href="javascript:bblist()">返回首页</a>
    /**
    * [bblist 跳首页]
    */
    function bblist() {
    document.location.href = APP_WEB_INDEX_ROOT_CDN + 'index' + HTML_TYPE + '?qntag=1#detailstate=' + detailstate + '&page=' + page + '&itemid=' + num_iid;
    }
    

      

  • 相关阅读:
    find
    fdisk
    falcon-eye
    ethtools
    e2fsck
    dpkg
    declare
    df
    debconf-utils
    区块链从零开始做开发(0):hyperledger Fabric2.3安装
  • 原文地址:https://www.cnblogs.com/wdlhao/p/4916628.html
Copyright © 2020-2023  润新知