-2

I want reload page after google extension.

there is background page code:

chrome.runtime.onMessageExternal.addListener(
  function(message, sender, sendResponse) {
    if(message.areYouThere) sendResponse(true);
  }
);

there is and add button code for webpage:

<button onclick="chrome.webstore.install()"
      id="install-button" style="display:none;">
      Add to Chrome
    </button>
    <script>
      if (chrome) {
        // The browser is Chrome, so we may need to show the button
        if(chrome.runtime && chrome.runtime.sendMessage) {
          // Some extension is ready to receive messages from us
          // Test it:
          chrome.runtime.sendMessage(
            "itemID",
            {areYouThere: true},
            function(response) {
              if(response) {
                // Extension is already installed, keep hidden
              } else {
                // No positive answer - it wasn't our extension
                document.getElementById('install-button').style.display = 'block';
              }
            }
          );
        } else {
          // Extension is not installed, show button
          document.getElementById('install-button').style.display = 'block';
        }
      }
    </script>

i want reload page after google extension. were i must put this code to do this function

document.getElementById('install-button').addEventListener("click", function(e) {
  chrome.webstore.install(function() {
    // Installation successful
    location.reload();
  });
}); 
web404
  • 33
  • 1
  • 7

1 Answers1

1

Right there.

This code from my answer is a replacement for your onclick attribute.

<button id="install-button" style="display:none;">
  Add to Chrome
</button>
<script>
  // Add a click handler
  document.getElementById('install-button').addEventListener(/* ... */);

  // Show if necessary
  if (chrome) {
    /* ... */
  }
</script>

(code taken out for brevity)

Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206
  • It is not reload page, plz chack code – web404 Jan 24 '15 at 12:38
  • Sorry, but _no_, I will not help you further. You have to use your brain sometimes - I don't see you trying. "plz put full code" is probably the worst thing you could say on Stack Overflow. – Xan Jan 24 '15 at 13:07
  • i am trying many times but it is not working , i will crate new question with full code witch i am useing – web404 Jan 24 '15 at 13:53