在 HTML 中为 target=“_blank”打开新窗口
<a href="facebook.com/sharer" target="_blank" >Share this</a>
当用户单击它时,如何在新窗口中使其具有一定的宽度和高度? 在firefox中,当前代码仅打开一个新选项卡(而不是新窗口)
<a href="facebook.com/sharer" target="_blank" >Share this</a>
How do I make this a certain width and height, in a new window, when the user clicks on it?
In firefox, the current code only opens up a new tab (not a new window)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要在包含尺寸和所有内容的新窗口中打开,您需要调用 JavaScript 函数,因为 target="_blank" 不允许您调整大小。一个例子是:
To open in a new windows with dimensions and everything, you will need to call a JavaScript function, as target="_blank" won't let you adjust sizes. An example would be:
您不能以这种方式影响类型(选项卡/窗口)或尺寸。为此,您必须使用 JavaScript 的 window.open() 。
You can't influence neither type (tab/window) nor dimensions that way. You'll have to use JavaScript's window.open() for that.
您无法通过裸露的
a
标签进行这种控制。但您可以连接标记的onclick
处理程序,以使用正确的参数调用window.open(...)
。请参阅此处的示例:https://developer.mozilla.org/En/DOM/Window.open
我仍然不认为你可以直接强制窗口位于选项卡上——这取决于浏览器和用户的设置。
You don't have that kind of control with a bare
a
tag. But you can hook up the tag'sonclick
handler to callwindow.open(...)
with the right parameters. See here for examples:https://developer.mozilla.org/En/DOM/Window.open
I still don't think you can force window over tab directly though-- that depends on the browser and the user's settings.