Html 目标“_blank”没有打开新窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16559765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 08:23:01  来源:igfitidea点击:

Target "_blank" not opening new window

html

提问by abiieez

I have an image map with one of the following entry

我有一个带有以下条目之一的图像映射

<area shape="poly" tooltip="Canada"
    onmouseover="setAreaOver(this,'world_canvas','0,0,255','255,0,0','0.5',1,0,0);cvi_tip._show(event);"
    onmouseout="setAreaOut(this,'world_canvas',0,0);cvi_tip._hide(event);"
    onmousemove="getCoords(event,'map_of_world','map_of_world_6','world',32,371,800,400,1903,2876);cvi_tip._move(event);"
    href="http://someurl.com"
    target="_blank"
id="map_of_world_6">

UPDATED

更新

I am using Google Chrome and I removed the coordsattribute from the snippet because it is too long.

我正在使用 Google Chrome 并coords从代码段中删除了该属性,因为它太长了。

Upon clicking on the area the main page goes to the url instead opening on the new page. Is this the right way to use target=_blank?

单击该区域后,主页将转到 url 而不是在新页面上打开。这是正确的使用方法target=_blank吗?

回答by Jukka K. Korpela

Your syntax for the targetattribute is correct, but browsers need not honor it. They may interpret it as opening the destination in a new tab rather than new window, or they may completely ignore the attribute. Browsers have settings for such issues. Moreover, opening of new windows may be prevented by browser plugins (typically designed to prevent annoying advertisements).

您的target属性语法是正确的,但浏览器不需要遵守它。他们可能会将其解释为在新选项卡而不是新窗口中打开目标,或者他们可能完全忽略该属性。浏览器有针对此类问题的设置。此外,浏览器插件可能会阻止打开新窗口(通常旨在防止烦人的广告)。

There's little you can do about this as an author. You might consider opening a new window with JavaScript instead, cf. to the accepted answer to target="_blank" is not working in firefox?, but browsers may be even more reluctant to let pages open new windows that way than via target.

作为作者,您对此无能为力。您可以考虑使用 JavaScript 打开一个新窗口,参见。对target="_blank"的公认答案在 Firefox 中不起作用?,但浏览器可能更不愿意让页面以这种方式打开新窗口,而不是通过target

回答by Joey G

onclick="window.open(this.href,'_blank');return false;"