12

I just spent the last 7 hours straight trying to find a way to link directly to a Chrome internal page. For now I have given up. I just instructed people to "right-click and open in new tab".

I have tried everything, from html to css to javascript, but nothing is working. Nothing happens when I click the link, even though right-clicking the link and opening it in a new tab works perfect.

Javascript failed attempts:

<div class="links">
  <a href="chrome://net-internals/" onclick="window.open('chrome://net-internals/');">TESTAA</a>
</div>

and

<div class="links">
  <a href="chrome://net-internals/" onclick="window.location('chrome://net-internals/');">TESTAA</a>
</div>

There is no error page. Simply nothing happens when you click. If you force it to open in a new tab using target="_blank", it only opens a blank tab.

UPDATE! SOLVED!

----- STEP 1-----

Place the following code in the background.html page (background.html is called in the manifest.json):

function openNetInternals() { 
  chrome.tabs.create({url: 'chrome://net-internals/'});
}

----- STEP 2 -----

Put this code for the link (in the html page):

<a href="chrome://net-internals/" onclick="chrome.extension.getBackgroundPage().openNetInternals()">Net</a>

----- STEP 3 -----

Make sure to refresh the extension. It will work now.

Michael Gaskill
  • 7,913
  • 10
  • 38
  • 43

3 Answers3

4

Is this link available from your extension or from your website? If from extension then try using chrome.tabs module:

chrome.tabs.create({url: 'chrome://net-internals/'});

On the background page create function like this one:

function openNetInternals() {
   chrome.tabs.create({url: 'chrome://net-internals/'});
}

And call it from your custom start page when link is clicked like this:

chrome.extension.getBackgroundPage().openNetInternals();

Relevant docs here.

OdraEncoded
  • 3,064
  • 3
  • 20
  • 31
Konrad Dzwinel
  • 36,825
  • 12
  • 98
  • 105
  • Sorry, but permissions have been given to tabs a long time ago. it has no effect. –  Jan 19 '12 at 12:58
  • I don't understand. What permissions are you talking about? – Konrad Dzwinel Jan 19 '12 at 13:05
  • nothing. ignore permissions. that is off-topic. I was only answering you telling you i had given the permissions to tabs. –  Jan 19 '12 at 13:11
  • okay, so let me try to get this straight. So are telling me to do this: **-----1-----** place the following code in my background.html page (I am using a background.html page): `function openNetInternals() { chrome.tabs.create({url: 'chrome://net-internals/'}); }` **-----2-----** Put this code for my link: `Net` . Is this correct? –  Jan 19 '12 at 14:07
  • Okay, with that code I get something new at least. Here is the error page. **`This webpage is not found No webpage was found for the web address: chrome-extension://svbtkuerandomlettersdjkfhsdh/chrome.extension.getBackgroundPage().openNetInternals();`** –  Jan 19 '12 at 14:17
  • You are using it wrong, try: `onclick="chrome.extension.getBackgroundPage().openNetInternals();"`. – Konrad Dzwinel Jan 19 '12 at 14:24
  • Okay I changed step 2 to this, thinking maybe this is what you meant: **-----2-----** Put this code for my link: `Net` However, once again nothing at all happens when I click the link. –  Jan 19 '12 at 14:25
  • Do you get any errors on console (ctrl+shift+j) when you click the link? – Konrad Dzwinel Jan 19 '12 at 14:27
  • let me check. yes, i do get an error. **Uncaught TypeError: Object [object DOMWindow] has no method 'openNetInternals'** **(anonymous function)** **Not allowed to load local resource: chrome://net-internals/** –  Jan 19 '12 at 14:32
  • OK, so it means that function you were supposed to put on background page (`openNetInternals`) is not there. That is why it is not working. Double check if this function is there, in ` – Konrad Dzwinel Jan 19 '12 at 14:35
  • It is definitely there. I double and triple checked to make sure I saved the document. It is within the script tags. I'm going to take a screenshot. –  Jan 19 '12 at 14:36
  • OK, but have you reloaded the extension after modifying background.html ? – Konrad Dzwinel Jan 19 '12 at 14:38
  • oh, ok let me reload the extension. ALso here is the screenshot (uploading it now) goo.gl/2dc38 –  Jan 19 '12 at 14:43
  • ahhhhhhhh! =DDDDDDDDDD yyyyyyyyyaaaaaaaaaaaayyyyyyyyyyyyyyy worksssssssss!!!!!!!!!!!!! I am releasing this extension for free, it is a very high quality extension. I was just stuck on this. I would be happy to reference you for your help! How can I reference you? –  Jan 19 '12 at 14:44
  • I don't think there is need for that :) I was happy to help. – Konrad Dzwinel Jan 19 '12 at 14:49
  • I get on average 5,000 to 10,000 new users a month for each extension I make. –  Jan 19 '12 at 14:52
  • I don't think you can. On stackoverflow there is even no way to send messages between users (AFAIK) :) – Konrad Dzwinel Jan 19 '12 at 14:55
  • well I found lots of other great advice from your profile and gave some up arrows - and honest ones too because it is good info. Reading your posts is like going to college again! =P –  Jan 19 '12 at 15:15
2

to open chrome:// link in new tab

chrome.tabs.create({url: 'chrome://net-internals/'});

to open in the same tab

chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
    var tab_id = tabs[0]['id'];
    chrome.tabs.update(tab_id, {'url':'chrome://net-internals/'});
});
yutictodiyo8fi
  • 101
  • 1
  • 4
1

Try this way:

<a href="#" onclick="chrome.tabs.create({url: 'chrome://net-internals'});">Net</a>
dfsq
  • 191,768
  • 25
  • 236
  • 258
  • 2
    `Note: This function can be used without requesting the 'tabs' permission in the manifest.` - http://code.google.com/chrome/extensions/tabs.html#method-create – Konrad Dzwinel Jan 19 '12 at 12:23
  • why is this not working? here is what i used: TESTBB –  Jan 19 '12 at 12:57
  • Where are you using this link? Context may be important. In a popup window? On the extension configuration page? – Konrad Dzwinel Jan 19 '12 at 13:04
  • It's not going to work from content scripts for example. You got to have `chrome.tabs` module available (like in background page). – dfsq Jan 19 '12 at 13:07
  • How can I make it work? Not in a popup window. Ideally it will open in the same window. it is only the settings page, which located in the same html page as the new tab page, which is a custom one I built. You know how you click a link to go to a website? That's all I want to do, only to go to an internal chrome page. –  Jan 19 '12 at 13:11
  • 2
    Try to `sendRequest` to the background page and from there invoke `chrome.tabs.create` – dfsq Jan 19 '12 at 13:17
  • oh, let me try to research about sendRequest. Can you give any leads? –  Jan 19 '12 at 13:43
  • I found this http://code.google.com/chrome/extensions/extension.html#method-sendRequest and this http://www.toptip.ca/2009/12/google-chrome-extensions-example-of-how.html, except I am not sure what data I am sending or recieving just so that the link opens the chrome url like chrome://net-internals –  Jan 19 '12 at 13:44