您的位置:首页 > 其它

location.hash 跨域

2010-06-01 10:57 127 查看
  功能:设置或返回被链接资源URL的锚字段(#部分)

  

  语法:location.hash

  锚字段是URL中的#部分。

  

  如:<a href="http://www.123.com/index.htm?K=5#part2">链接</a>。

  其中锚字段是“#part2”。

  说明:hash属性没有对应的HTML属性,它实际上是href属性值中的一部份。

  

<!--location.hash是"#t3" -->
<a id="LK" href="http://www.123.com/index.htm?F=10#t3" target="_blank">链接</a>
<div>

<script type="text/javascript">
document.write("目标地址:" + document.getElementById("LK").href);
document.write("<br />锚字段:" + document.getElementById("LK").hash);
document.write("<br />锚字段:" + document.getElementById("LK").hash.split("#")[1]);
</script>

</div>

  location.hash可以跨域,用这个属性可以实现跨越传参数,具体实例引用这几篇文章

http://hi.baidu.com/beluker/blog/item/1c1ca5f683566365ddc474fd.html

http://www.xiahaixia.com/tag/js/

http://hi.baidu.com/beluker/blog/item/1c1ca5f683566365ddc474fd.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: