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;
}

  

window.location.hash 页面跳转,精确定位,实例展示:的更多相关文章

  1. 关于window.location.href页面跳转的坑

    "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...

  2. 完好用户体验: 活用window.location与window.open解决页面跳转问题

    原文地址: JavaScript Redirects and window.open原文日期: 2014年08月27日翻译日期: 2014年08月31日翻译人员: 铁锚 (译者注: 本文解决的是按 C ...

  3. window.location.hash(hash应用)---跳转到hash值制定的具体页面

    location是javascript里边管理地址栏的内置对象,比如location.href就管理页面的url,用location.href=url就可以直接将页面重定向url.而location. ...

  4. window.location.hash

    我们知道JavaScript中很早就提供了window.history对象,利用history对象的forward().go().back()方法能够方便实现不同页面之间的前进.后退等这种导航功能.但 ...

  5. window.location.hash在firefox下中文自动转码为UTF-8问题

    1.window.location.hash window.location.hash这个属性主要是读取和写入网页位置的,我们经常会用来控制网页单页面跳转或者是控制网页位置.然而这个属性在firefo ...

  6. window.location.hash属性介绍

    location是javascript里边管理地址栏的内置对象,比如location.href就管理页面的url,用location.href=url就可以直接将页面重定向url.而location. ...

  7. 一个简单的样例看明确怎样利用window.location.hash实现ajax操作时浏览器的前进/后退功能

    我们知道JavaScript中非常早就提供了window.history对象,利用history对象的forward().go().back()方法可以方便实现不同页面之间的前进.后退等这样的导航功能 ...

  8. window.location.hash 使用说明

    本文给大家详细汇总了关于window.location.hash的知识点,属性以及用法等等,非常的实用,并附上了例子,有需要的小伙伴可以参考下.   location是javascript里边管理地址 ...

  9. window.location.hash 使用

    [转]http://www.cnblogs.com/nifengs/p/5104763.html location是javascript里边管理地址栏的内置对象,比如location.href就管理页 ...

随机推荐

  1. Python入门-模块1(模块导入与time模块)

    ---恢复内容开始--- 模块 一.模块分类: 模块分为三种: 1.内置模块:Python自带的标准模块(可使用help('modules’)查看Python自带模块列表) 2.第三方开源模块:可以通 ...

  2. 铁乐学python_Day42_锁和队列

    铁乐学python_Day42_锁和队列 例:多个线程抢占资源的情况 from threading import Thread import time def work(): global n tem ...

  3. docker 自制CentOS 6-lnp镜像

    环境准备 1台centos 6.5镜像虚拟机  febootstrap.docker febootstrap 安装 yum install -y yum-priorities && r ...

  4. RAC数据库的RMAN备份异机恢复到单节点数据库

    1.首先在rac环境用rman备份数据库.[oracle@rac1 admin]$ rman target /run{allocate channel c1 device type disk conn ...

  5. 张高兴的 Windows 10 IoT 开发笔记:使用 MAX7219 驱动数码管

    This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#. GitHub:https://github.co ...

  6. 在web.xml中配置404错误拦截

    <error-page> <error-code>404</error-code> <location>/home.do</location> ...

  7. php解决约瑟夫环的问题

    php里面解决约瑟夫环还是比较方面的,但是下面的方法太费空间 <?php class SelectKing{ private $m;//幅度 private $n;//总数 public fun ...

  8. Echarts 多曲线“断点”问题解决方法

    Echarts 用来做可视化曲线是非常优秀的一个库.建议使用 Echarts 作为项目的可视化图标库时,仔细研究 官方实例,根据需求来选择类似的示例,下载实例模板来开发,节省时间,减少出错,提高效率. ...

  9. cocos2d-x(十一)Lua开发飞机大战-6-加入子弹

    接下来我们为飞机加入子弹,首先创建一个BulletLayer: module("BulletLayer",package.seeall) local bulletBatchNode ...

  10. highcharts柱状图实现legend和数据列一一对应效果

    var cate = ['Green', 'Pink']; Highcharts.chart('container', { chart: { type: 'column' }, legend: { e ...