Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening new window in HTML for target="_blank"

<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)

like image 783
TIMEX Avatar asked Mar 29 '10 21:03

TIMEX


People also ask

What is the target for a hyperlink that needs to open in a new window?

The target attribute set to _blank , which tells the browser to open the link in a new tab/window, depending on the browser's settings.

What does target _blank mean in HTML?

Value. Description. _blank. Opens the linked document in a new window or tab.

How do I make a link open in a new window?

Open in a new window To open a link in a new browser window, hold the Shift on then click the link or right-click the link and select Open link in New Window.

How do I make a link open in a new tab instead of a new window?

The first method requires a keyboard and a mouse or trackpad. Simply press and hold the Ctrl key (Cmd on a Mac) and then click the link in your browser. The link will open in a new tab in the background.


2 Answers

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:

<a href="http://www.facebook.com/sharer" onclick="window.open(this.href, 'mywin', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" >Share this</a> 

Hope this helps you.

like image 111
Marcos Placona Avatar answered Oct 07 '22 17:10

Marcos Placona


You can't influence neither type (tab/window) nor dimensions that way. You'll have to use JavaScript's window.open() for that.

like image 42
Pekka Avatar answered Oct 07 '22 18:10

Pekka