1.获取URL
获取url的方法,直接用location就可以了,window.location或window.loation.href也可以。
-
<script language="javascript">
-
var t1=location;
-
var t2=window.location;
-
var t3=window.location.href;
-
document.write("location="+t1+"<br />"+"window.location="+t2+"<br />"+"window.location.href="+t3);
-
</script>
2.分析URL
运用location获取的url的属性为object,要对其进行字符串" title="字符串">字符串的分析操作,需要先将其转换为字符串" title="字符串">字符串。
-
<script language="javascript" type="text/javascript">
-
var t1=location;
-
var t2=window.location;
-
var t3=window.location.href;
-
document.write("location类型为: "+typeof(t1)+"<br />"+"window.location类型为: "+typeof(t2)+"<br />"+"window.location.href类型为: "+typeof(t3));
-
</script>
用location来进行处理,首先将其转换为字符串" title="字符串">字符串,用函数toString(
阅读全文>>