-2

I created a popup in Chrome extension that works just fine.

where in the popup, user will click on a button and open a new tab and loads a index.html that comes with the extension package locally.

the index.html hv it's own .js files, css, etc.

however, when a button is clicked inside the index.html, with window.open("url"), chrome failed to open a new window/tab from that page.

error message:

Refused to display 'https://www.behance.net/' in a frame because it set 'X-Frame-Options' to 'DENY'.

what can i do the perform window.open() in a tab that is created by chrome extension?

adrian li
  • 457
  • 8
  • 19
  • Please [edit] your question to be on-topic: Questions seeking debugging help ("**why isn't this code working?**") must include: ►the desired behavior, ►a specific problem or error *and* ►the shortest *complete* code necessary to reproduce it **in the question itself**. Questions without a clear problem statement are not useful to other readers. See: "**How to create a [mcve]**", [What topics can I ask about here?](http://stackoverflow.com/help/on-topic), and [ask]. – Makyen Aug 31 '16 at 22:32
  • Maybe these two posts can help: https://stackoverflow.com/questions/23555592/refused-to-display-in-a-frame-because-it-set-x-frame-options-to-deny-facebook https://stackoverflow.com/questions/14915152/loading-iframe-facebook-load-denied-by-x-frame-options – Alex Susanu Aug 31 '16 at 22:44
  • Is that button inside an IFRAME? Another method would be to postMessage to the main document which will be able to use [chrome.tabs.create](https://developer.chrome.com/extensions/tabs#method-create) (requires "tabs" permission). – wOxxOm Sep 01 '16 at 07:03

1 Answers1

0

After some digging around I found the solution to it. it was easier than i thought.

for some reason window.open("url") is not working

the magic is to use this function to trigger a click event instead:

winUrl(x){
     var a = document.createElement('a');
    a.href = x;
    a.target='_blank';
    a.click();
  };

again I am new to coding so i m not so sure what is happening that fixed all the errors.

would someone care to comment and explain?

adrian li
  • 457
  • 8
  • 19