我想用js輸出一個a的超鏈接,鏈接的內容想用location對象獲取可以么?怎么實現?
<!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> ??
2016-10-27
document.getElementsByTagName('a')[i].href
i表示第幾個a標簽。
2016-10-27
var lk=location.href
<a href=lk>點擊</a>
思路大概是這樣子吧,我也不太懂
2016-10-27
你現在獲取的是window對象的url,也就是當前瀏覽器的URL,如果想獲取a鏈接的,就這樣