Close button opens new chrome store tab on Chrome extension popup

266 views
Skip to first unread message

Ben Mildren

unread,
May 19, 2016, 6:50:04 AM5/19/16
to Chromium-Extensions-Announce

We have a Chrome extension download button on our site.


When you click it, it opens a popup that says 'Add extension', 'Cancel' etc.


The image shows the popup I'm referring to.

It works fine, except for the cancel button opens a new tab and takes you to the plugins chrome store page.

I have no idea why it does this, or how to just get it to cancel.


The js:

chrome.webstore.install(link, () => null, (error, errorCode) => {
if (errorCode !== 'userCanceled') {
window.open(link, '_blank');
}
});
}


I assumed the errorCode would be 'userCanceled' because the user hits the cancel button, so I excluded that. The list of errors are here: https://developer.chrome.com/extensions/webstore


Any help is much appreciated.


Antony Sargent

unread,
May 19, 2016, 1:05:01 PM5/19/16
to Ben Mildren, Chromium-Extensions-Announce
You should not be calling window.open - see https://developer.chrome.com/webstore/inline_installation for the full documentation, but you should have something like the following:

page.html
<!DOCTYPE html>
<html>
<head>
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/YOUR_ID_GOES_HERE">
</head>
<body>
Install my awesome thing: <button id="do_install">begin</button>
<script src="page.js"></script>
</body>
</html>


page.js

function onSuccess() {
  console.log("yay, install succeeded");
}

function onFailure(reason) {
  console.log("install did not succeed because: " + reason);
}

document.getElementById("do_install").onclick = function() {
  chrome.webstore.install(onSuccess, onFailure);
};






--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/ec68d8fb-9fa4-4339-89b2-177ed4aee254%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Reply all
Reply to author
Forward
0 new messages