因此,我想在一家报社时获得一个选定的表格的html。 但是,有些工作要做。 什么是失踪?
mani.4/1999/.json
{
"name": "extension",
"version": "1.0",
"description": "discription",
"content_scripts": [
{
"matches": ["http://www.google.com/*"],
"js": ["contentscript.js"]
}
],
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
},
"permissions": [
"http://ajax.googleapis.com/",
"tabs"
]
}
popup.html
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script>
</head>
<body>
<script>
function getHTML()
{
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {method: "getHTML"}, function(response) {
if(respond.method="getHTML"){
alert(response.html);
}
});
});
}
</script>
<input type="submit" value="OK" onclick ="getHTML()" />
</body>
contentscript.js
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
if(request.method == "getHTML"){
sendResponse({html: document.all[0].outerHTML});
}
}
);