<ul class="test">
<li>
<a href="abc.com">abc.com</a>
<a href="xyz.com">xyz.com</a>
</li>
</ul>
如何在页面加载时在新窗口中打开URL上方的URL。在页面加载时在新窗口中打开URLS
<ul class="test">
<li>
<a href="abc.com">abc.com</a>
<a href="xyz.com">xyz.com</a>
</li>
</ul>
如何在页面加载时在新窗口中打开URL上方的URL。在页面加载时在新窗口中打开URLS
**I got the solution: Thanks to everyone for your help.**
<ul class="test">
<li>
<a href="abc.com">abc.com</a>
<a href="xyz.com">xyz.com</a>
</li>
</ul>
<script type='text/javascript' >
$(document).ready(function(){
$(".test li a").each(function(){
url = $(this).attr("href");
window.open(url,'_blank')
});
})
</script>
使用特定的选择选择
a
元素,并使用window.open
这些元素的href
属性
$('a').each(function() {
window.open(this.href);
});
你有添加target="_blank"
<a href="abc.com" target="_blank">abc.com</a>
<a href="xyz.com" target="_blank">xyz.com</a>
您的意思是当你用这个html打开页面时,它会打开其他窗口而不点击任何东西? – Dhunt
@Dhunt:是的,它会打开,没有点击链接。 – harry