Does the hotkey plugin open a new window even if pop-ups are blocked?

I want to open a new window if the "F2" button is pressed. Below code gives me newWindow is nullerror message in firefox. If I do not use a popup blocker, it works. Same thing in IE. It works in chrome mode even with a pop-up blocker.

using jstree pre 1.0 stable

            hotkeys: {
                "f3" : function () {
                url = "http://www.vse.cz";
                var newWindow = window.open(url, '_blank');
                newWindow.focus();
                return false;

            },

Q1: Can I make it work for all browsers so that users do not have to change their settings when using the hotkeys plugin?

Q2: How did it work Using JavaScript instead of the goal to open new windows works without any problems in firefox? Is it because it is a link and not using hotkey plugins?


I understand that the script from the page above manipulates what happens when the user clicks on the link. It changes the properties of the click so browsers "don’t know" that this is a new window, so the pop-up blocker is bypassed.

In my case, I am using a pure js function called by something else, and not a user click. And this “my function” does not change the properties of any html objects. I think that is the difference. I'm not sure I'm right here.

+5
source share
1

, , ( ).

, IE, Firefox Chrome ( ), ( window.open), JavaScript, , — , . , , , -, DOM.

, ; . , " ", . Mozilla change, click, dblclick, mouseup, reset submit., ( , IE .)

, – keydown/keyup/keypress – do , , window.open null.

Chrome keydown, , script .

, , . :

  • spawn(), window.open, .
  • spawn() . , ; .
  • window.onkeydown, spawn(). Chrome, , keydown. IE Firefox , .
  • , spawn(). , , window.open click.

, , "" , , . , , , , -, , , . window.open , (, ), , , [] .

, ( ), .

+7

All Articles