JQuery open link in new window with small size (NOT TAB)

I need to open certain links in a new window (NOT TAB) with specific sizes.

This will open the link in a new tab:

$(document).ready(function() { $('a[rel|=external]').click(function(){ window.open(this.href); return false; }); }); 

What needs to be changed to open links in new windows?

EDIT: This is my entire javascript file:

 $(document).ready(function() { $('a[rel=external]').click(function(){ window.open(this.href); return false; }); $('a[rel=external-new-window]').click(function(){ window.open(this.href, "myWindowName", "width=800, height=600"); return false; }); }); 

HTML:

 <a href="/clientarea/utils/law/id/2832" rel="external-new-window" class="accessible-link">Β§5, odsek 2</a> 
+4
source share
5 answers

You can pass window.open() sizes for this:
Edited for an updated question: note that [rel|= changed to [rel= .

 $(document).ready(function() { $('a[rel|=external]').click(function(){ window.open(this.href); return false; }); $('a[rel=external-new-window]').click(function(){ window.open(this.href, "myWindowName", "width=800, height=600"); return false; }); });​ 

You can test it here , with dimensions other than the tab being the key here. Keep this in mind, although it can still open on a tab , there are many browser options, extensions, and plugins to prevent pop-ups.

In addition, from the user's point of view, too many pop-ups encourage me to hunt you and hit you in the eye with a salad fork and / or pop up a window and throw you out of it, so please use this sparingly.

+20
source

Set the target attribute to _blank and do not return false.

 $(document).ready(function() { $('a[rel|=external]').click(function(){ $(this).attr('target', '_blank'); }); }); 
0
source

use _blank

Example

 window.open(this.href, '_blank'); onClick="window.open('http://www.functionx.com/javascript', '_blank');" > 
0
source
Syntax

window.open ():

 window.open(URI, window name, parameters); 
  • URI: location as a string
  • window name: unique identifier, only valid characters are allowed: [AZ, az, 0-9, _]
  • : height, width, left, screenX, screenY , etc. etc.

Example:

 window.open(this.href, "unicorn", "width=400, height=600, screenX=100"); 
0
source

If ff is configured to open new windows on tabs, you cannot open a new window, but instead a tab.

-1
source

Source: https://habr.com/ru/post/1315512/


All Articles