zwei1121

博客园 首页 新随笔 联系 订阅 管理

<html>

<head>

<title>js获取上一页url,js获取前一页地址,javascripts获取上一页url,javascript获取前一页地址</title>

<meta http-equiv="keywords" content="" />

</head>

<body>

<script language="javascript">

document.write("js获取当前域名"+window.location.host+"或者"+document.domain+"<br>");

document.write("js获取当前url"+window.location.href+"<br>");

document.write("js获取上(前)一页url"+document.referrer);

</script>

</body>

</html>

 

以上是获取的代码,以下是具本的应用:

 

在<body>中插队入

<script language="javascript">
function goUrl(){
window.location.href=document.referrer;
}
</script>

然后在返回链接上这样写:

<a href="javascript:goUrl();">返回上一页</a>

posted on 2013-10-17 11:48  zwei  阅读(59668)  评论(0编辑  收藏  举报