0

I want to inject a script file into a panel window in chrome extension.

    chrome.windows.create({
          width:500,
          height:500,
          type:"panel",
          url:'http://url/',
    },function(win){
        var a=win.tabs[0];
        chrome.tabs.executeScript(a.id,{file:"test.js"},function(){
            console.log("hello");
        })  
   })

This produces the error :

 tabs.executeScript: No tab with id: 186

But if I change type of window to popup , everything works fine , the code in test.js is executed in context of the url in popup.

Also , chrome.tabs.query() returns all tabs except if a window is of panel type

How can I achieve the same thing with window of type panels?

Is it because panel is not fully tested in chrome or am I doing something wrong.

karyboy
  • 317
  • 1
  • 5
  • 22
  • possible duplicate of [How to insert HTML/JS into window (of type "panel") created by chrome.windows.create?](http://stackoverflow.com/questions/16723337/how-to-insert-html-js-into-window-of-type-panel-created-by-chrome-windows-cr) – Rob W Nov 23 '13 at 19:08
  • @RobW: The question you mention is about opening some local HTML/JS in a panel's tab. This one is about injecting a content script in a panel's tab that points to an external URL. The way I see it, the two questions are totally different. – gkalpak Nov 23 '13 at 19:17
  • 1
    @ExpertSystem Both questions are about inserting HTML/JS in a panel. The other question has a single answer (from the OP) that showed a solution that works in his specific case, but that does not make the question any different. As I indicated in [a comment](http://stackoverflow.com/questions/16723337/how-to-insert-html-js-into-window-of-type-panel-created-by-chrome-windows-cr#comment30019695_16723337) on the question itself, the feature is currently unavailable because of a [bug in Chromium](https://code.google.com/p/chromium/issues/detail?id=319270). – Rob W Nov 23 '13 at 20:02
  • @ExpertSystem I checked out the bug page , I am getting the same error .. – karyboy Nov 23 '13 at 20:09
  • This works for me on Chrome 31.0.1650.57 m for Windows. You should inform your OS and Chrome version in the bug report. – rsanchez Nov 23 '13 at 20:41
  • @rsanchez I tried my code on 31.0.1650.57 m for Windows , now the error is gone , but the script does not execute for type panel... are u able to inject the script ? – karyboy Nov 23 '13 at 21:58
  • Yes, it works for me. I tried a simple `console.log` and it shows in the panel window's console. – rsanchez Nov 23 '13 at 22:07
  • @rsanchez ohh , in my case , the panel window's console doesnt open.. right clicking it crashes chrome (https://code.google.com/p/chromium/issues/detail?id=168998) , and pressing f12 doesnt work either .. u r on windows 7 or 8 ? – karyboy Nov 24 '13 at 05:26
  • FYI you can just use content_scripts to achieve this. No need to fuss with tab IDs – Sean Anderson Jul 15 '15 at 21:40

0 Answers0