使用Chrome的历史记录API无法删除网址 [英] Cannot delete URLs with Chrome's history API
问题描述
我使用 Chrome浏览器的历史记录API来制作Chrome扩展程序,以从我的历史记录中移除某些网址,一>。以下是目前的代码:
document.addEventListener('DOMContentLoaded',function(){
var form = document.getElementById('form'),
query = document.getElementById('query')
form.onsubmit = function(e){
e.preventDefault()
/ / alert(chrome.history)// [object Object]
// alert(chrome.history.deleteUrl)// function(){[native code]}
// alert(query.value) //任何我输入
chrome.history.deleteUrl(query.value)
}
query.focus()
})
( 您可以从三个 这是我的 我使用Chrome的版本 您不应该将字符串传递给 错误:窗体history.deleteUrl(string)的调用与定义history.deleteUrl(对象细节,可选函数回调)不匹配 总之,更改 至 I am making a Chrome extension to remove certain URLs from my history, using Chrome's history API. Here is the code so far: ( As you can see from the three Here is my I am using version You should not pass a string to the Error: Invocation of form history.deleteUrl(string) doesn't match definition history.deleteUrl(object details, optional function callback) In summary, change to
这篇关于使用Chrome的历史记录API无法删除网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! form
是我的弹出窗体, query <
警报
s,变量很好。但是,代码实际上并未从历史记录中移除网址。当我检查( chrome:// history /
)时,网址仍然存在。
manifest.json
,如果那么重要:
{
manifest_version:2,
name:UnVizit,
description:将链接标记为\未访问过\\,
version: 0.1.0,
permissions:[
history
],
browser_action:{
default_icon:icon.png ,
default_popup:popup.html
}
}
28.0.1500.95(官方版本213514)m
。
chrome.history.deleteUrl
方法,但是包含关键url的对象。如果您检查弹出窗口,您将看到以下错误:
chrome.history.deleteUrl(query.value)
chrome.history.deleteUrl({url:query.value});
document.addEventListener('DOMContentLoaded', function() {
var form = document.getElementById('form'),
query = document.getElementById('query')
form.onsubmit = function(e) {
e.preventDefault()
// alert(chrome.history) // [object Object]
// alert(chrome.history.deleteUrl) // function () { [native code] }
// alert(query.value) // whatever I typed
chrome.history.deleteUrl(query.value)
}
query.focus()
})
form
is the form in my popup, and query
is the text box in which you can type.)alert
s, the variables are fine. However, the code isn't actually removing the URL from the history. When I check (in chrome://history/
), the URLs are still there.manifest.json
, if that matters:{
"manifest_version": 2,
"name": "UnVizit",
"description": "Mark a link as \"not visited\" easily",
"version": "0.1.0",
"permissions": [
"history"
],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
}
}
28.0.1500.95 (Official Build 213514) m
of Chrome.chrome.history.deleteUrl
method, but an object with key url. If you inspect your popup, you would see the following error:
chrome.history.deleteUrl(query.value)
chrome.history.deleteUrl({ url: query.value });