Google Chrome Cookies扩展程序:“Can not call method'set'of undefined” [英] Google Chrome Cookies Extensions: "Cannot call method 'set' of undefined"
问题描述
我在开发Chrome扩展程序时尝试使用Google Chrome Cookie扩展程序。我已按照此处的说明进行操作: http://code.google.com/chrome/ extensions / cookies.html
I'm trying to use the google chrome cookies extension when developing a chrome extension app. I've followed the instructions found here: http://code.google.com/chrome/extensions/cookies.html
我的清单文件已经有权限和cookie。
My manifest file already has the permissions and cookies.
问题现在我似乎无法调用饼干扩展中的任何方法
The problem is now I can't seem to call any of the methods in the cookies extension
var newCookie = {'url:': 'http://*/*', 'name': 'routeCookie', 'value': route.tag[document.boxForm.routeBox.options.selectedIndex]};
chrome.cookies.set(newCookie);
错误:未捕获的类型错误:无法调用方法未定义
Error: UnCaught TypeError: Cannot call method 'set' of undefined
推荐答案
我敢打赌,您正试图从内容脚本运行它。大多数API方法仅在后台页面中可用。
I bet you are trying to run it from a content script. Most API methods are available only in background pages.
这篇关于Google Chrome Cookies扩展程序:“Can not call method'set'of undefined”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!