简体   繁体   English

如何将超链接打开为具有给定宽度和高度的弹出窗口?

[英]How can I make a hyperlink open as a popup with a given width and height?

I have a hyperlink that is: 我有一个超链接:

 <a href="some.html">Test</a>

If I click on the Test link, some.html should open as pop up menu with some given width & height. 如果我单击Test链接, some.html应该打开弹出菜单,其中包含一些给定的宽度和高度。

How can I do this? 我怎样才能做到这一点?

You can use window.open() : 你可以使用window.open()

<a href="javascript:window.open('some.html', 'yourWindowName', 'width=200,height=150');">Test</a>

Or: 要么:

<a href="#" onclick="window.open('some.html', 'yourWindowName', 'width=200,height=150');">Test</a>

Using target='_blank' sometimes opens in a new tab, and it usually does for Firefox and Chrome. 使用target='_blank'有时会在新标签页中打开,通常用于Firefox和Chrome。 Your best best is to use Frédéric's code: 你最好的是使用Frédéric的代码:

<a href="javascript:window.open('some.html', 'yourWindowName', 'width=200,height=150');">Test</a>

To open in popup, you can use target="_blank" : 要在弹出窗口中打开,可以使用target="_blank"

<a href="some.html" target="_blank">Test</a>

Or use window.open : 或者使用window.open

<a href="#" onclick="window.open('some.html', 'win', 'width=400,height="400"')">Test</a>

没有锚元素和没有新的弹出窗口工具栏的简单方法

<span class="popup" onClick="javascript:window.open('http://www.google.com', '_blank','toolbar=no,width=250,height=250');">

Try use this code : 尝试使用此代码:

<a href="javascript: void(0)" onclick="window.open('yourLink','_blank','width=900,height=300');">Try</a>

Using javascript: void(0) to make no any contact of previous page after you click popup window. 单击弹出窗口后,使用javascript: void(0)不与上一页进行任何联系。

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

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