<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>