1

I have just started developing chrome extension ( Using chrome 34).

My aim is to check for a ID attribute in a site by opening it in multiple languages.

For instance, whenever I open that website, and click on my extension link. The extension should open the website in multiple languages in background, and check if a html "ID" exists.

As a start, I want to get the current URL for that site.

manifest.json -

{
 "manifest_version": 2,

  "name": "Hello World!",
  "description": "My extension",
  "version": "1.0",

  "browser_action": {
   "default_icon": "icon.png",
   "default_popup": "popup.html"
 },

 "permissions": [
    "tabs",
    "http://*/*",
    "https://*/*"
]

 }

My popup.html is

  <script type="text/javascript" src="currentUrl.js"/>

and currentUrl.js is

chrome.tabs.query({'active': true, 'windowId': chrome.windows.WINDOW_ID_CURRENT},
  function(tabs){
    alert(tabs[0].url);
  }
 );

But it is not working to alert the current URL. Whenever I click extension, just a small blank window appears.

Novice User
  • 3,552
  • 6
  • 31
  • 56
  • Right click the button and choose "Inspect popup". Does the console show any error or warning or anything? Also, do not forget to add a DOCTYPE to any HTML file you create - start any HTML file with ` `, or else it would be rendered in a legacy compatibility mode, called Quirks Mode that adds some non standard, unexprected behaviors. – PhistucK May 04 '14 at 22:04
  • Console log shows nothing. Added DOCTYPE.still no luck. – Novice User May 04 '14 at 22:08
  • Keep using the "Inspect popup". Add `debugger;` before the `alert` and see what the `tabs` variable holds when the debugger breaks. – PhistucK May 04 '14 at 22:13
  • 1
    Change your script tag to: `` – rsanchez May 05 '14 at 07:42
  • I see you already found out in http://stackoverflow.com/questions/23463220/chrome-extension-access-dom-after-chrome-tabs-update – rsanchez May 05 '14 at 08:12
  • Possible duplicate of http://stackoverflow.com/q/17379190/2336725 – Teepeemm May 05 '14 at 09:03

0 Answers0