1

I want to open a new window but instead of having that window as like like it does, i want it to make it as a tabbed view.

I have tried the following:

var strWindowFeatures = "location=yes,height=570,width=520,scrollbars=yes,status=yes";
var URL = "https://www.website.com/cws/share?mini=true&url=" + location.href;
var win = window.open(URL, "_blank", strWindowFeatures);

The above opens as a new window i.e popup. And i tried the below for new pop

var win = window.open(url, '_blank');
  win.focus();

But i tried combining the above to procedures but with no luck. could someone tell me if its possible at all and or how to go about it. Thanks!

EDIT:

Actually i went through all the answers before asking, and this will explain how my question is different.

A pop up looks like this (and i know how to open it): pop up image

And a new tab looks like this: new tab image

Simply put, i want to convert the popup in image 1 to the new tab structure in image 2.

mega-crazy
  • 838
  • 2
  • 17
  • 36
  • https://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-and-not-a-new-window-using-javascript – snnsnn May 18 '18 at 19:12
  • 1
    You can't control how a new window is opened, it is a user preference in the browser settings. – Asons May 18 '18 at 19:12
  • Possible duplicate of [Open a URL in a new tab (and not a new window) using JavaScript](https://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-and-not-a-new-window-using-javascript) – Asons May 18 '18 at 19:13
  • You cannot convert an already-opened window. – SLaks May 22 '18 at 03:28

1 Answers1

0

Someone answered here.

  function openInNewTab(url) {
      var win = window.open(url, '_blank');
      win.focus();
    }

openInNewTab('http://www.google.com');

I've tried this code sample my self, in my browser's console and it worked fine.

Like the person who answered in the link above said, try calling openInNewTab() in onclick event of your DOM to prevent pop-up blockers.

You can try copy pasting the following line in your browser's console (tested on Firefox and Chrome).

It should open google in a new tab:

window.open('http://www.google.com', '_blank').focus();