Skip to content Skip to sidebar Skip to footer

Chrome Extension : Stop Loading The Page On Launch

I would like to stop the page loading when I click the extension icon. I have a background page , I need an option similar to window.stop() when I click the extension Icon. If the

Solution 1:

You can always do this (requires host permissions or activeTab):

chrome.browserAction.onClicked.addListener(function(tab) {
    chrome.tabs.executeScript(tab.id, {
        code: "window.stop();",
        runAt: "document_start"
    });
});

I am not sure what happens with manifest-defined content scripts. It's possible that scripts defined with run_at other than document_start will not be injected; in this case you can use executeScript's callback to inject them in any case, and put in some guard code in the content script to prevent it from executing twice:

// content.js
if(contentInjected) return;
var contentInjected = true;

/* rest of the code */

Post a Comment for "Chrome Extension : Stop Loading The Page On Launch"