4

I want to open a tab inside an opened window. Something like this

(it should open a new window with "google.co.uk" with a new tab "google.de"

newWindow = window.open('http://www.google.co.uk', '', 'width=10');
newWindowTab = newWindow.open('http://www.google.de', '_blank');

but this opens "newWindowTab" only in the window, where this code is.

I have also tried this, to give the window time to load, until it (should) open the new tab:

newWindow = window.open('http://www.google.co.uk', '', 'width=10');
setTimeout(function() {
    newWindowTab = newWindow.open('http://www.google.de', '_blank');
}, 500);

But then I get:

Error: Permission denied to access property "open"

I have used firefox. I heard that it might be possible to do in Chrome, but I want to use this script in Firefox.

isherwood
  • 58,414
  • 16
  • 114
  • 157
TheEquah
  • 121
  • 8
  • 1
    Pretty much the only way to get external content shown within a constrained space **in** your page is to use an `iframe`, so you could do this by managing a group of `iframe`s you show/hide via a tab bar. **However**, Google is unlikely to allow you to put an `iframe` around it. – T.J. Crowder Jun 04 '15 at 15:22
  • possible it will help you [Link](http://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-using-javascript) – The Reason Jun 04 '15 at 15:44
  • @The I have already seen this. But it opens only a new tab in the "main window", where the code is. – TheEquah Jun 04 '15 at 16:04
  • @T.J.Crowder It could be a good solution, but it should open an external webpage and i need to access the document inside it. This is not possible with frames, because of XSS (http://en.wikipedia.org/wiki/Cross-site_scripting) – TheEquah Jun 04 '15 at 16:08
  • @TheEquah: It's not possible *at all* (other than with CORS and such). – T.J. Crowder Jun 04 '15 at 16:28

1 Answers1

0

This is not possible, unless the window being opened is from the same origin (ie the same domain). MDN says this:

The reference can be used to access properties and methods of the new window provided it complies with Same origin policy security requirements.

erikvold
  • 15,988
  • 11
  • 54
  • 98