Chrome扩展程序弹出窗口中的Google图表? [英] Google Chart in Chrome Extension Popup?

查看:116
本文介绍了Chrome扩展程序弹出窗口中的Google图表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的Chrome扩展程序的弹出式页面显示一个Google图表,显示有关用户新闻阅读习惯的信息。我注意到(特别是在这里: Chrome扩展不起作用),这是一个问题Chrome扩展程序不允许内联脚本,这会使包含使用Google图表所需的API文件变得复杂。有没有解决的办法?是否有某处我可以下载整个API以简单地包含在我的扩展中? 解决方案

您无法使用Google如果文档位于Chrome扩展程序的上下文中,则会违反内嵌JavaScript规则。但是,您可以将iframe放入引用远程资源的扩展的弹出窗口中。例如,如果以下代码段位于您的弹出式窗口中:

 < iframe src =https://mycoolextension.com/用户/ 12345\" >< / iframe中> 

然后,您可以在地址 https://mycoolextension.com/user/12345 。如果要将图表与扩展的数据集成,则需要将参数添加到图表iframe的地址,或者实现内容脚本以将值传递到iframe。


I would like to have my Chrome extension's popup page display a Google Chart that shows information on the user's news-reading habits. I notice (particularly here: Chrome extension doesn't work) that a problem with this is that Chrome extensions do not allow inline script, which complicates including the necessary API files to use Google Chart. Is there a way around this? Is there somewhere where I can download the entirety of the API to simply include in my extension?

解决方案

You can't use Google Charts if the document is in the Chrome extension's context because it violates the inline-JavaScript rule. However, you can put an iframe into the extension's popup that references a remote resource. For instance, if the below snippet is in your popup:

<iframe src="https://mycoolextension.com/user/12345"></iframe>

Then you can have an application using Google Charts available at the address https://mycoolextension.com/user/12345. If you want to integrate the charts with the extension's data, you will either need to add parameters to the chart iframe's address, or implement a content script to message values into the iframe.

这篇关于Chrome扩展程序弹出窗口中的Google图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆