日期:2014-05-16 浏览次数:20731 次
<ul class="menu">
<li href="a.html">a</li>
<li href="b.html">b</li>
<li href="c.html">c</li>
</ul>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<ul class="menu" id='mm'>
<li href="a.html">a</li>
<li href="b.html">b</li>
<li href="c.html">c</li>
</ul>
<script>
var $lis = document.querySelectorAll('.menu li');
var i=0;
var dochref = location.href.substring(0,(location.href.lastIndexOf('/')+1));
for(;i<$lis.length;i++){
$lis[i].onclick = (function(href){
return function(){
window.open(dochref+href);
}
}($lis[i].getAttribute('href')))
}</script>
</body>
</html>