Error During Tabs.executescript Unknown Error
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up chrome.tabs.executeScript shows unknown error up vote 1 down vote favorite 1 This is my code which I use for geolocation. It does not log the coordinates to the console even though I have console.log. It shows an error saying "chrome/ExtensionProcessBindings:95 Error during tabs.executeScript: Unknown error." However, when asked to alert; it alerts the right coordinates background.html script chrome.tabs.executeScript(null, {file: "content_script.js"}); content_script.js navigator.geolocation.getCurrentPosition(function(position) { console.log(position.coords.latitude+" "+position.coords.longitude); }); manifest.json { "name" : "Geolocation", "version" : "0.1", "background_page" : "background.html", "permissions":["tabs","http://*/*", "https://*/*","*://*/*"] } geolocation google-chrome-extension share|improve this question edited Jul 15 '11 at 15:34 asked Jul 15 '11 at 15:21 user782400 40031231 Does it work if you inject content script through manifest? –serg Jul 15 '11 at 15:25 Sorry, I dint understand what you mean. But i've edited my question with my manifest.json file too –user782400 Jul 15 '11 at 15:30 In your manifest you are already injecting content_script.js to all pages automatically. If you want to inject it on demand then remove "content_scripts":... from your manifest. –serg Jul 15 '11 at 15:32 @serg : i edited the manifest with what you said. Is that right ? –user782400 Jul 15 '11 at 15:35 Yes, did it help? –serg Jul 15 '11 at 15:36 | show 1 more comment 1 Answer 1 active oldest votes up vote 2 down vote accepted Your code works fine for me. I think the problem is that you are calling chrome.tabs.executeScript() right in the beginning of a background page, which means it probably tries to inject this
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each http://stackoverflow.com/questions/6709352/chrome-tabs-executescript-shows-unknown-error other. Join them; it only takes a minute: Sign up how to check tab load failed up vote 5 down vote favorite 2 I need do something on tabs updated, like check if the page load correct, and replace something inside the page. here is my code // background.js chrome.tabs.onUpdate.addListener(function(tabId, changeInfo, tab){ try{ chrome.tabs.executeScript(tabId, filename); } catch(e) { http://stackoverflow.com/questions/10221359/how-to-check-tab-load-failed // 1. when I open a new tab // 1. Error during tabs.executeScript: Unknown error. // 2. when I request a url not arrive-able. // 2. Error during tabs.executeScript: Cannot access contents of url // "data:text/html,chromewebdata". Extension manifest must request // permission to access this host. // but I can't catch these errors, they just appers in background console. } }); I try to executeScript when it upload, but if the current tab is chrome://newtab or chrome error page, I can't do this, but I can't catch the error. javascript google-chrome google-chrome-extension browser-tab share|improve this question edited Sep 3 '12 at 18:59 hippietrail 5,89145186 asked Apr 19 '12 at 3:41 guilin 桂林 5,4491764112 add a comment| 2 Answers 2 active oldest votes up vote 11 down vote There's no direct way to catch these errors. However, I've just created a method to accomplish the goals: Use chrome.tabs.onUpdated (with a d!). This event is fired twice, when the page is initializing ("loading"), and when the DOM has loaded ("complete"). Use chrome.tabs.executeScript(tabId, {file: fileName}, fn_callba
sandbox pages Starred by 5 users Reported by downch...@gmail.com, Jan 26 2013 Back to list Status: WontFix Owner: ort...@chromium.org Closed: Dec https://bugs.chromium.org/p/chromium/issues/detail?id=172432 2015 Cc: jyasskin@chromium.org, kalman@chromium.org, mpcomplete@chromium.org, yoz@chromium.org Components: Platform>Extensions OS: All Pri: 2 Type: Bug Via-Wizard Sign in to add a comment UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17 Steps to reproduce the problem: 1. Create a sandbox page as well as a background or extension error during page. 2. Run chrome.windows.create to open the sandbox page and return a new tab object. 3. Run chrome.tabs.executeScript on the new tab object. What is the expected behavior? The sandbox page should be injected via executeScript with a content script. What went wrong? An unknown error is returned. WebStore page: Did this work before? error during tabs.executescript No Chrome version: 24.0.1312.56 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Similar to issue #146201 Comment 1 by downch...@gmail.com, Jan 26 2013 Processing Other similar issues: #159977, #127975, #31947 and #30756 Project Member Comment 2 by bugdroid1@chromium.org, Mar 10 2013 Processing Labels: -Feature-Extensions Cr-Platform-Extensions Comment 3 by miket@chromium.org, Apr 18 2013 Processing Labels: Needs-Feedback Please attach a zip of a small unpacked extension demonstrating this problem. Comment 4 by downch...@gmail.com, Apr 19 2013 Processing Attached; creates a sandbox page and attempts to run executeScript demonstration in it to turn the page red. It binds to context menu to launch the example, so just context menu then hit Open. 175202.zip 1.9 KB Download Comment 5 by scheib@chromium.org, May 10 2013 Processing Owner: yoz@chromium.org Status: Assigned yoz, please help triage. I don't see anyone in https://docs.google.com/a/google.com/spreadsheet/ccc?key=0As3QSHWWzerGdC1yNVRobWsyR1JPQmN0aVNPcnR4anc#gid=1 for sandboxed pages (was mihaip I think), and you're on tabs. Comment 6 by yoz@chromium.org, May 10 2013 Processing Cc: kalman@chromium.org jya