蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

location属性详解#?(已解决)

为了方便学习理解,做了个示例页面,不过最后一个属性不理解,为什么会是undefine
[html]
<script>
function ml(){
var t='';
t+='<a href="javascript:window.location.href=\'#hash\';ml();">hash</a> 以散列号(#)开始的一个字符串,用于指定URL内的一个锚点:';
t+=document.location.hash+'<br>';
t+='host 包括冒号和端口号的URL的主机名部分:';
t+=document.location.host+'<br>';
t+='hostname 与host属性相同,除了不包括冒号和端口号之外:';
t+=document.location.hostname+'<br>';
t+='href 完整的URL:';
t+=document.location.href+'<br>';
t+='pathname URL的目录路径部分:';
t+=document.location.pathname+'<br>';
t+='port URL的:端口部分:';
t+=document.location.port+'<br>';
t+='protocol URL的类型(http:、ftp:、gopher:等等):';
t+=document.location.protocol+'<br>';
t+='<a href="'+document.location.search+'">search</a> 以问号(?)开始的URL中的一部分,用于指定搜索信息:';
t+=document.location.search+'<br>';
t+='target 用户单击链接(TARGET特性)时,用于显示被引用文档的内容的窗口:';
t+=document.location.target+'<br>';
document.body.innerHTML=t;
}
</script>
<body onload="ml()">
</body>
[/html]

location属性详解#?

[html]
<script>
for (a in document.location)
  document.write("document.location."+a+"&nbsp;&nbsp;&nbsp;&nbsp;<b>"+document.location[a]+"</b><br/>");

</script>
[/html]

location属性详解#?

谢谢!原来location没有target属性,看来是资料有误
另外说说我的心得:
hash和search都可以用来在页面之间或者内部传递参数
但是
hash比较适合在只需要前台局部处理,不需要页面重载情况下传递参数
search则适合在需要后台参与或者需要页面重载得情况下传递参数




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com