Alex Daro Alex Daro - 2 years ago 253
C++ Question

Load HTML page after chrome.tabs.onCreated

I am trying to load a static HTML file after I have opened a new tab. This code will act as a Chrome extension. I am stuck in an infinite loop and don't know how to proceed.

Here is my manifest.json:

"manifest_version": 2,

"name": "Getting started example",
"description": "This extension shows a Google Image search result for the current page",
"version": "1.0",

"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html",
"default_title": "Click here!"

"background": {
"scripts": ["background.js"]

"permissions": [

Here is my background.js (chrome.tabs.create will result in an obvious endless loop):

chrome.tabs.onCreated.addListener(function(tab) {
// chrome.tabs.create({url: chrome.extension.getURL('mypage.html')});

How can I achieve this? Do I have to dynamically create the HTML in JavaScript? Or can I load a static HTML file?

Answer Source

Chrome extensions have an explicit option in the manifest for replacing certain pages, chrome_url_overrides.

For example:

"chrome_url_overrides": {
   "newtab": "mypage.html"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download