<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>document[referrer]_windows_location_href</title>
<style>
body input{
width: 200px;
height: 50px;
background: lightgreen;
margin: 50px auto;
}
</style>
<script type="text/javascript">
window.onload = function(){
// document.referrer 获取上一个跳转页面的地址. (此方法需要服务器支持)
// var iUrl = document.referrer(); 需要使用变量接受数据.
// location属性使用.
var fnBtn = document.getElementById('btn01');
fnBtn.onclick =function (){
var iUrl = window.location.href; //获取原本url地址(需转码),
window.location.href = "http://www.baidu.com"
// 转换现有网址为等号后的url
// 后缀, 可以转换网址, 可以作为a标签使用
//
alert(iUrl);
};
}
</script>
</head>
<body>
<input type="button" value="百度" id="btn01">
</body>
</html>