Murilo
Murilo

Reputation: 49

Open window to add chrome extension when the page loads

I'm trying to create a javascript that opens the option of adding a chrome extension when the page is loading. I have this script below. What am I doing wrong, it does not work?

   <script>
    function onPageLoad(event)
    {
        javascript:chrome.webstore.install();
    }

    document.addEventListener("DOMContentLoaded", onPageLoad, true);
    </script>

Upvotes: 0

Views: 81

Answers (1)

cviejo
cviejo

Reputation: 4398

This is not allowed and will throw an exception, chrome.webstore.install() can only be called after a user gesture, like a click. Here is the documentation for this.

Upvotes: 1

Related Questions