js获取上一页、当前页及域名url方法,JS反回上一页的方法


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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM