javascript中获取浏览器的url
document.location
location.href(与location.toString()一样)
location
document.URL
在IE中document.URL与其它三个稍有不同
IE6~7(假设文件保存的桌面上,location.html)
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write(location.href);
document.write("<br>");
document.write(location);
document.write("<br>");
document.write(document.location);
document.write("<br>");
document.write(document.URL);
//-->
</SCRIPT>
结果为:
file:///C:/Documents%20and%20Settings/Administrator/桌面/location.html
file:///C:/Documents%20and%20Settings/Administrator/桌面/location.html
file:///C:/Documents%20and%20Settings/Administrator/桌面/location.html
file://C:\Documents and Settings\Administrator\桌面\location.html
在firefox,Opera,Google中四个语句展示结果均相同