Bipin
Bipin

Reputation: 71

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.

How can I do this?

Upvotes: 6

Views: 89035

Answers (5)

Kijiya
Kijiya

Reputation: 31

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.

Upvotes: 1

Mohamed Saligh
Mohamed Saligh

Reputation: 12349

easy way to implement without the anchor element and without the new popup window toolbar

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

Upvotes: 1

Fred
Fred

Reputation: 4221

Using target='_blank' sometimes opens in a new tab, and it usually does for Firefox and Chrome. Your best best is to use Frédéric's code:

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

Upvotes: 6

Fr&#233;d&#233;ric Hamidi
Fr&#233;d&#233;ric Hamidi

Reputation: 263077

You can use 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>

Upvotes: 12

Sarfraz
Sarfraz

Reputation: 382841

To open in popup, you can use target="_blank":

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

Or use window.open:

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

Upvotes: 3

Related Questions