Google Chrome extension - stop browser navigation

511 views
Skip to first unread message

Mihai Moga

unread,
Dec 15, 2011, 6:00:27 AM12/15/11
to Chromium-extensions
How do I stop browser navigation from a Google Chrome extension?

chrome.experimental.webRequest.onBeforeRequest.addListener(function(details)
{
alert("webRequest.onBeforeRequest -- Navigation blocked");
return {cancel: details.url.indexOf("bing.com") != -1};
}, {}, ["blocking"]);

The above code doesn't work!

Dominic Battre

unread,
Dec 15, 2011, 5:06:11 PM12/15/11
to Mihai Moga, Chromium-extensions
I see a couple of potential problems, depending on which version of Chrome you are using:

Daily builds of Chrome
- use chrome.webRequest instead of chrome.experimental.webRequest
- require "webRequest" and "webRequestBlocking" permission for your purpose in the manifest.json file
- require a host permission in the manifest.json file (something like ["*://bing.com/*", "*://*.bing.com/*"] for your example)

Best regards,
Dominic



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.




--
Dominic Battré | Software Engineer | bat...@google.com | +49 (0) 89 - 83 930 9152

Reply all
Reply to author
Forward
0 new messages