<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>location</title>
</head>
<script type="text/javascript">
document.write(window.location.href);
</script>
</head>
<body>
</body>
</html>
document.getElementsByTagName('a')[i].href
i表示第几个a标签。
var lk=location.href
<a href=lk>点击</a>
思路大概是这样子吧,我也不太懂
你现在获取的是window对象的url,也就是当前浏览器的URL,如果想获取a链接的,就这样
var a = document.getElementByTagName(a)[0] alert(a.location.href)