Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5949809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:18:11+00:00 2026-05-22T17:18:11+00:00

I want to open new window if F2 pressed. Below code gives me newWindow

  • 0

I want to open new window if “F2” pressed. Below code gives me newWindow is null error message in firefox. If I don’t use pop-up blocker it works. The same in IE. It work in chrome even with pop-up blocker on.

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 users don’t have to change their settings when using hotkeys plugin?

Q2: How come Using JavaScript instead of target to open new windows works without any troubles in firefox? Is that because it’s a link and not using hotkeys plugin?


My understanding is that the script from above page somehow
manipulates what happens
when user clicks a link. It changes the properties of the click so
browsers “don’t know” that it’s new window so pop-up blocker is
bypassed.

In my case I use pure js function triggered by something else, not by
a user click. And that ‘my function’ doesn’t changes properties of any html objects. I think this is the difference. I am not sure if I am
right here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:18:12+00:00Added an answer on May 22, 2026 at 5:18 pm

    Unfortunately, there’s nothing you can do to open a new window on a keypress (other than disabling the popup blocker).

    The way that the popup blockers in IE, Firefox and Chrome work (from a high level) is by the browser (upon encountering a call to window.open) walking up the JavaScript call stack to determine if the current function is—or was called by a function that is—an event handler. In other words, it finds out if the current function is executing because the user did something that triggered a DOM event.

    If so, then the popup is allowed; otherwise it is blocked. However, the question of which events qualify as “popup-allowing” vary by browser. By default in Mozilla, only change, click, dblclick, mouseup, reset, and submit qualify. (I assume IE is similar.)

    Functions that are event handlers for any other type of event – such as keydown/keyup/keypress in your case – do not qualify for special popup-allowing treatment, which means your popup is blocked and is why your call to window.open returns null.

    Chrome, however, does consider the keydown event eligible for allowing popups to be opened, which is why your script works in that browser.

    Here’s a reduced example to demonstrate how this works. This demo:

    • Defines a function called spawn() which calls window.open to open a popup.
    • Calls spawn() immediately as the page is loaded. This is blocked by all browsers since the call is made from the global scope; it is not called from an event handler.
    • Attaches a function to window.onkeydown which calls spawn(). If you press any key in Chrome, the popup will open because it allows popups from keydown handlers. In IE and Firefox, the popup will be blocked becuase those browsers do not allow popups from keyboard events.
    • Attaches an event handler to the link which calls spawn(). When you click the link, the popup will be allowed in all browsers because the call to window.open can be traced back to an event handler for a click event.

    As you can now see, nothing goes on to manipulate event properties or “trick” the browser in to not knowing that there’s a new window. The behavior of popups being allowed to open from link clicks is by design, the theory being that if you’ve clicked on something, it’s likely that you want to see whatever is in the popup. However, when a call is made to window.open from a place where you’ve not done anything (such as the global scope), it’s likely you do not have any interest in whatever [ad] is in the automatically-launching popup.

    In this way, popup blockers prevent annoyances (automatically launching ads) while still allowing pages to open popups at the user’s request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've opened a new window with window.open() and I want to use the reference
I have the code below to open a new window whenever user presses F2
I want to open a new window in button click.I have used a code.
In my site I want to open a new window with a url .My
I am new to C# and WPF. I want to open a new window
In my javascript i want to open URL in new window with this method:
I want to open new url as a popup window on form submission. Can
I want to open All external link into new window/tab through php without touching
I want to open a new window with a textfield that copies what you
I want to open a new window and carry over some of the HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.