Browser link open new windows

I know that its bit old Q but if u get here by searching a solution so i got a nice one via jquery

  jQuery('a[target^="_new"]').click(function() {
    var width = window.innerWidth * 0.66 ;
    // define the height in
    var height = width * window.innerHeight / window.innerWidth ;
    // Ratio the hight to the width as the user screen ratio
    window.open(this.href , 'newwindow', 'width=' + width + ', height=' + height + ', top=' + ((window.innerHeight - height) / 2) + ', left=' + ((window.innerWidth - width) / 2));

});

it will open all the <a target="_new"> in a new window

EDIT:

1st, I did some little changes in the original code now it open the new window perfectly followed the user screen ratio (for landscape desktops)

but, I would like to recommend you to use the following code that open the link in new tab if you in mobile (thanks to zvona answer in other question):

jQuery('a[target^="_new"]').click(function() {
    return openWindow(this.href);
}


function openWindow(url) {

    if (window.innerWidth <= 640) {
        // if width is smaller then 640px, create a temporary a elm that will open the link in new tab
        var a = document.createElement('a');
        a.setAttribute("href", url);
        a.setAttribute("target", "_blank");

        var dispatch = document.createEvent("HTMLEvents");
        dispatch.initEvent("click", true, true);

        a.dispatchEvent(dispatch);
    }
    else {
        var width = window.innerWidth * 0.66 ;
        // define the height in
        var height = width * window.innerHeight / window.innerWidth ;
        // Ratio the hight to the width as the user screen ratio
        window.open(url , 'newwindow', 'width=' + width + ', height=' + height + ', top=' + ((window.innerHeight - height) / 2) + ', left=' + ((window.innerWidth - width) / 2));
    }
    return false;
}

Hi pw9571, yes, actually, there is a preference for that, but you need to dig a bit for it. I’m going to show all three of these related preferences:

(1) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button promising to be careful or accepting the risk.

(2) In the search box above the list, type or paste neww and pause while the list is filtered

(3) Review/Adjust the preferences as follows:

(A) browser.link.open_newwindowfor links in Firefox tabs

This is the one that has a checkbox on the Preferences page:

  • 3 = divert new window to a new tab (default)
  • 2 = allow link to open a new window
  • 1 = force new window into same tab

(B) browser.link.open_newwindow.restrictionfor links in Firefox tabs

By default, if a page sets width, height, or toolbars for a popup, Firefox will let it be a separate window. To force those into a tab as well, you can change this preference to 0:

  • 0 = apply the setting under (A) to ALL new windows (even script windows with features)
  • 2 = apply the setting under (A) to normal windows, but NOT to script windows with features (default)
  • 1 = override the setting under (A) and always use new windows

(C) browser.link.open_newwindow.override.externalfor links in other programs

  • -1 = apply the setting under (A) to external links (default)
  • 3 = open external links in a new tab in the last active window
  • 2 = open external links in a new window <= Try this one
  • 1 = open external links in the last active tab replacing the current page

To return to normal if things go haywire, right-click each «modified» preference and choose Reset.

Success?

I know that its bit old Q but if u get here by searching a solution so i got a nice one via jquery

  jQuery('a[target^="_new"]').click(function() {
    var width = window.innerWidth * 0.66 ;
    // define the height in
    var height = width * window.innerHeight / window.innerWidth ;
    // Ratio the hight to the width as the user screen ratio
    window.open(this.href , 'newwindow', 'width=' + width + ', height=' + height + ', top=' + ((window.innerHeight - height) / 2) + ', left=' + ((window.innerWidth - width) / 2));

});

it will open all the <a target="_new"> in a new window

EDIT:

1st, I did some little changes in the original code now it open the new window perfectly followed the user screen ratio (for landscape desktops)

but, I would like to recommend you to use the following code that open the link in new tab if you in mobile (thanks to zvona answer in other question):

jQuery('a[target^="_new"]').click(function() {
    return openWindow(this.href);
}


function openWindow(url) {

    if (window.innerWidth <= 640) {
        // if width is smaller then 640px, create a temporary a elm that will open the link in new tab
        var a = document.createElement('a');
        a.setAttribute("href", url);
        a.setAttribute("target", "_blank");

        var dispatch = document.createEvent("HTMLEvents");
        dispatch.initEvent("click", true, true);

        a.dispatchEvent(dispatch);
    }
    else {
        var width = window.innerWidth * 0.66 ;
        // define the height in
        var height = width * window.innerHeight / window.innerWidth ;
        // Ratio the hight to the width as the user screen ratio
        window.open(url , 'newwindow', 'width=' + width + ', height=' + height + ', top=' + ((window.innerHeight - height) / 2) + ', left=' + ((window.innerWidth - width) / 2));
    }
    return false;
}

Contents

  • 1 Background
  • 2 Possible values and their effects
    • 2.1 1
    • 2.2 2
    • 2.3 3
  • 3 First checked in
  • 4 Has an effect in
  • 5 Related bugs
  • 6 Related preferences

Background

Some web sites choose to open certain links in new windows. This preference lets you control where to open these links, that would normally open new windows. You can use browser.link.open_newwindow.restriction to fine tune which links will be affected by this preference.

Possible values and their effects

1

Open links, that would normally open in a new window, in the current tab/window.

2

Open links, that would normally open in a new window, in a new window (Default in Firefox 1.5 and older).

3

Open links, that would normally open in a new window, in a new tab in the current window (Default in Firefox 2.0 and newer).

First checked in

2004-10-03 by Dan Matejka

Has an effect in

  • Mozilla Firefox (all versions since 1.0)
  • SeaMonkey (all versions)

  • Bug 172962 — Options for where to open URLs from other applications (reuse tab, new tab, new window)

  • browser.link.open_newwindow.restriction
  • browser.link.open_external

Скажите, как в браузере (гугл хром или яндекс — не имеет значения) — сделать так, чтобы при открытии ссылки — иногда просто бывают всплывающие окна — по работе приходится работать в системе оки-токи (но это просто так, отступление) — чтобы все открывалось в новой вкладке а не окне (т.е. чтобы вторая копия браузера не открывалась?
В мозилле есть инструкция как это сделать… но оно не подходит, нужен именно хром… а в хроме или в яндексе не знаю как реализовать подобное (хотя почти уверен, что есть такая возможность).

Может кто-то знает? посоветуйте пожалуйста.
вот то что я нашел для мозиллы — оно работает нормально только в мозилле..

Поменяйте настройки в about:config

browser.link.open_newwindow (Целое) — как открывать ссылки, в которых указано открытие новых окон. Значения:
1 – Открыть в текущей вкладке
2 – Открывать в новом окне
3 – Открывать в новой вкладке

browser.link.open_newwindow.restriction (Целое) — Позволяет открывать вкладки вместо новых окон. Значения:
0 – открывать все ссылки в вкладках
1 – Открывать ссылки в окнах
2 – Открывать ссылки в вкладках за исключением случаев, когда заданны нестандартные параметры окна (например изменение размера)

  • Browser exe что это за процесс windows 10
  • Btc tools скачать бесплатно на русском для windows 10
  • Broken android data extraction скачать на русском бесплатно для windows
  • Broadcom официальный сайт драйвера windows 10
  • Bt dongle10 драйвер windows 10