繁体   English   中英

使用self.location在新标签页中打开页面?

[英]to open a page in new tab using self.location?

我正在使用self.location="www.google.com"; 在我的代码中打开Goog​​le页面。 我如何在另一个窗口中打开同一页面。

您可以使用window对象open方法,如下所示:

window.open("www.google.com");

您可以使用<a>标记并设置target="_blank"属性以在新标签页/窗口中打开页面。 是否在新标签页/窗口中打开它完全取决于用户代理中的设置。

<a href="http://www.google.com" target="_blank">Google</a>

尝试这个

window.open ("www.google.com","mywindow");
<script>
function fullwin(targeturl) {
window.open(targeturl,"","fullscreen,scrollbars")
}
</script>

<form>
<input type="button" onClick="fullwin('mypage.html')" value="Show My Frameset">
</form>

我看到至少一种怪异的方法:

<a id='newwnd' href='goole.com' style='display:hidden' target='blank'></a>
...
document.getElementById('newwnd').click();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM