chrome.history.deleteUrl not working
I just tried chrome.history.deleteURL
in an HTML page and it's not working. Can anyone say where I am going wrong?
Urls.html:
<!DOCTYPE HTML>
<html>
<head>
<title>Your History</title>
<style>
body {min-width: 300px;}
</style>
<script type="text/Javascript">
function deleteURL(form){
var urlName = form.url.value;
chrome.history.deleteUrl(urlName);
}
</script>
</head>
<body>
<form onSubmit="deleteURL(this);">
Enter url here : <input type="text" name="url" />
<input type="submit" value="submit" />
<开发者_开发知识库/form>
</body>
</html>
manifest.json:
{
"name": "Browser History",
"version": "1.0",
"description": "Shows up the history",
"permissions": [
"history",
"tabs"
],
"browser_action": {
"default_popup": "Urls.html",
"default_icon": "history.jpg"
}
}
After executing the program I can still see the URL which I wanted to delete.
Although I have never used the chrome.history.* API before your code looks like it should work.
Have you remembered to add the required permission to your manifest?
Edit:
Doh! I just realised that your API call is invalid. Try using this updated version of the deleteUrl
function;
function deleteURL(form){
chrome.history.deleteUrl({
url: form.url.value
});
}
Notice that I've wrapped the argument in an object with a url
property as per the API. Don't know why I didn't see that earlier.
精彩评论