如何模拟target =" _blank"在JavaScript中 [英] How to simulate target="_blank" in JavaScript
本文介绍了如何模拟target =" _blank"在JavaScript中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户点击链接时,我需要更新数据库中的字段,然后在新窗口中打开请求的链接。更新没问题,但我不知道如何打开新窗口而不要求他们点击另一个超链接。
When a user clicks on a link, I need to update a field in a database and then open the requested link in a new window. The update is no problem, but I don't know how to open a new window without requiring them to click on another hyperlink.
<body onLoad="document.getElementById('redirect').click">
<a href="http://www.mydomain.com?ReportID=1" id="redirect" target="_blank">Report</a>
</body>
推荐答案
<script>
window.open('http://www.example.com?ReportID=1', '_blank');
</script>
第二个参数是可选的,是目标窗口的名称。
The second parameter is optional and is the name of the target window.
这篇关于如何模拟target =" _blank"在JavaScript中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文