0

I want emulate the default behavior of the browser like when a link is activated with the middle button of the mouse.

I catch the mousedown to open a new windows.

$('.msk-table-items').mousedown(function (event) {
    if (event.which == 2) {
        var url = $(this).data('href');
        window.open(url, '_blank'); se cambie a la nueva pestaña?
    }
});

It works, but changes tab.

I clarify that I want do this on some labels that are not hyperlinks.

Is this possible?

EDIT:

This is an example of a label for this

<tr class="msk-table-items" data-sujetoid="11578" data-href="/Detail/11578">...</tr>

What i am looking for...

I make a selectable list in a table, when one item or many was selected, the web shows options like save in a group, activate, delete, etc...

If the user make a double click in the item, it open, but if the user make a click on it with the middle button, the item open in a new tab.

I want to open the new tab without change the focus to it, the linked solution is not working for me.

function openNewBackgroundTab() {
var a = document.createElement("a");
a.href = window.location.pathname;
var evt = document.createEvent("MouseEvents");
//the tenth parameter of initMouseEvent sets ctrl key
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
                            true, false, false, false, 0, null);
a.dispatchEvent(evt);

}

function seleccionables() {

$('table.tab-sujetos').selectable({
    filter: 'tr',
    cancel: '.clickeable',
    stop: function () {
        var arr = [];
        $(".ui-selected", this).each(
            function () {
                var sujetoId = $(this).data('sujetoid');
                arr.push(sujetoId);
            }
        );
        $("." + $(this).data("select")).val(arr);
        //  show the actions menu
        if (arr.length == 1) {
            displaySimples();
            displayMultiples();
        }
        else if (arr.length > 1) {
            ocultaSimples();
            muestraMultiples();
        }
        else {
            ocultaSimples();
            ocultaMultiples();
        }


        //  open a element with double click
        if ($(".ui-selected", this).length == 1) {
            $(".ui-selected", this).first().addClass("clickeable").delay(800).queue(
                function (next) {
                    $(this).removeClass("clickeable");
                    next();
                }
            );
        }
    }
});

$('.msk-table-items').mousedown(function (event) {
    if (event.which == 2) {
        var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
        if (!is_chrome) {
            var url = $(this).data('href');
            window.open(url, '_blank');
        }
        else {
            openNewBackgroundTab();
        }
    }
});

//  2.2 Double click
$(".msk-table-items").dblclick(function () {
    var url = $(this).data('href');
    window.location = url;
});
Maske
  • 824
  • 2
  • 17
  • 35
  • I don't think you can do this anymore in Chrome. It used to be possible, but it's a classic "pop-under", mostly used for annoying stuff, so Chrome removed all possibilities to do this, as far as I know. – adeneo Mar 17 '16 at 16:05
  • What are you exactly looking for ? you want like a false url ? or you want to open a new html page, or import one in an other ? – Nathan Schwarz Mar 17 '16 at 16:05
  • i want open a set of items of the table at time, and finally go to the open tabs. but not open up one at time. the linked answer doesn't work anymore, so... it is not possible? – Maske Mar 17 '16 at 17:52

0 Answers0