Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I open a tab with a html-button while being on the chrome web store?

I have got a page in my frontend with different buttons, all buttons, on their own, work perfectly, but if I click the button that opens an extension in the chrome web store and click on another button afterwards, the page doesn't open.

Here is an exmaple of what I am talking about. If you click the buttons without closing the tabs that are opening, the button you click after the chrome web store opens won't have an effect. Does anybody know why that is and how to work around that?

https://html-ichr7r.stackblitz.io

Here is the code for it.

<button id="button1" onclick="window.open('https://www.facebook.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button2" onclick="window.open('https://www.google.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>

<button id="button3" onclick="window.open('https://chrome.google.com/webstore/detail/dark-mode/dmghijelimhndkbmpgbldicpogfkceaj?hl=de','popup','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button4" onclick="window.open('https://www.9gag.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>

Any help is appreciated!

EDIT: I just figured out that it works in firefox, still don't know why it doesn't work in Chrome though.

like image 934
Ckuessner Avatar asked Dec 02 '19 21:12

Ckuessner


1 Answers

I have somewhat of a solution: for your Google webstore link change popup to something else like popupWindow, so you'll have:

<button id="button1" onclick="window.open('https://www.facebook.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button2" onclick="window.open('https://www.google.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>

<button id="button3" onclick="window.open('https://chrome.google.com/webstore/detail/dark-mode/dmghijelimhndkbmpgbldicpogfkceaj?hl=de','popupWindow','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button4" onclick="window.open('https://www.9gag.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>

You will have actually have two different popups with this code.

About the explanation, I am a bit in the dark with this one. I think Chrome is preventing executing JS on https://chrome.google.com/webstore/* as a security measure. You can read more about similar issues here and here here.

Addition (after having some thoughts about it):

This is probably a smart move by the developers of Chrome. By not allowing any JS to alter any of the pages on https://chrome.google.com/webstore/, they are sure that also no extension can possibly alter this page. Immagine if you install an extension that does the thing in advertises quite well so it will get a positive score, while it also alters the page of the extension webstore. It could trick users into installing additional (hacky/adware-ish) extensions or software that would infect the users browser or computer.

like image 110
Dirk J. Faber Avatar answered Nov 15 '22 18:11

Dirk J. Faber