» 网友学堂 » Javascript教程 » 用javascript取得当前页面的url路径
用javascript取得当前页面的url路径
作者:暖月 发表时间:2006-7-29 18:55 阅读:1561次 在百度搜索相关内容

以下代码只实现读取功能,读取单独页面URL。框架页面URL,嵌入页面URL等功能。

以下是代码:

<script>
alert("1: " + window.location.href);
alert("2: " + window.location);
alert("3: " + location.href);
alert("4: " + parent.location.href);
alert("5: " + top.location.href);
alert("6: " + document.location.href);
</script>


函数使用多样化,大家可以根据需要来分别需要的代码。如本贴左上部分的复制本贴连接,使用的是1类读取。

#Advertisement