[英]Google.Load ['table'] does nothing in Chrome content-script
I am creating a Chrome Extension
that utilises a content-script
to insert a Google Visualisation Table into a page once it has finished loading. 我正在创建一个
Chrome Extension
,该Chrome Extension
可以在完成加载后利用content-script
将Google可视化表插入页面。 The problem though is that the table is never displayed - it is also not in the html as can be seen from the images below. 问题是,该表从不显示-从下面的图像可以看出,它也没有出现在html中。
Manifest.json Manifest.json
{
"manifest_version": 2,
"name": "blah",
"version": "1.0",
"permissions": [
"tabs", "http://*/*"
],
"web_accessible_resources": [
"jquery-1.10.2.min.js",
"jquery-1.10.2.min.map"
],
"content_scripts": [
{
"matches": ["http://*.ebay.co.uk/*"],
"js": ["jquery-1.10.2.min.js", "jsapi.js", "myScript.js"],
"run_at": "document_end"
}]
}
MyScript.js MyScript.js
$('#cbrt').after('<div id=\'google_table_div\'></div>');
google.load('visualization', '1', { packages:['table'], callback : function() { drawTable(); } });
function drawTable()
{
alert('draw');
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('number', 'Salary');
data.addColumn('boolean', 'Full Time Employee');
data.addRows([
['Mike', {v: 10000, f: '$10,000'}, true],
['Jim', {v:8000, f: '$8,000'}, false],
['Alice', {v: 12500, f: '$12,500'}, true],
['Bob', {v: 7000, f: '$7,000'}, true]
]);
var table = new google.visualization.Table(document.getElementById('google_table_div'));
table.draw(data, {showRowNumber: true});
}
The alert
in the callback never happens. 回调中的
alert
永远不会发生。 Here is the HTML at the end: 这是最后的HTML:
You need to load the 'table' package as well. 您还需要加载“表”包。 Like so:
像这样:
packages:['corechart', 'table']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.