location.hash 跨域

   功能:设置或返回被链接资源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

 

   

 

posted @ 2010-06-01 10:57  艾伦  阅读(1010)  评论(0编辑  收藏  举报