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

  • SEARCH
  • Home
  • 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 7800875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:46:38+00:00 2026-06-02T00:46:38+00:00

I realize that you cannot control whether a browser opens a new window vs.

  • 0

I realize that you cannot control whether a browser opens a new window vs. a new tab, so this may have no solution.

The problem is basically that I run something like:

function runCommand() {
   //...
   window.open(url);
}

This runs from time to time if the user presses a special key or clicks. That all works fine, and it will open a new window or tab based on the user’s browser settings. Great.

The problem is, I also have some code:

if (x.property) runCommand();

This will always open a the url in a new window, even though if you use runCommand at some other time on the same page, it will use a tab if that’s the user’s setting.

At first, I thought that it may have had to do with the page not being fully loaded, so I both tried wrapping it in document.ready and also using setTimeout() to some high number (like 5 seconds). Even after doing that, runCommand() will still open a new window on the initial run even though it opens a new tab later on. Has anyone experienced this behavior or know how to fix it?

EDIT: I created a fiddle that showcases the problem. Please excuse the popup: http://jsfiddle.net/csPGU/

  • 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-06-02T00:46:40+00:00Added an answer on June 2, 2026 at 12:46 am

    I’m guessing it’s something to do with the browser itself and the way that the browsers try to deal with windows that are opened programatically.

    I assume that when you runCommand later on it’s based on an event that has occurred (clicking on something for instance). Browsers generally allow new windows that are triggered by events, but block those that had no interaction (typically popups).

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

Sidebar

Related Questions

I realize that this question has been asked 100times but none that I have
I realize that enum cannot be used as a generic constraint, and Microsoft has
I realize that the answer to this question is likely quite obvious (if somewhat
(I realize that my title is poor. If after reading the question you have
I have a class, Target<T> that cannot be altered, with a generic constraint. I
This is a school assignment and I have most of it under control, but
I realize that you cannot iterate over a Dictionary in C# and edit the
My problem is that the browser windows vertical scrollbar that is removed by for
I realize that this question is not unlike asking someone for the name of
I realize that a whole lot of code cannot fit here, but I am

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.