如何嵌入谷歌趋势图在HTML? [英] How to embed google trend chart in html?

查看:102
本文介绍了如何嵌入谷歌趋势图在HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一个网站在网页上嵌入了互动的Google趋势图表:,有嵌入的脚本,可以复制并粘贴到HTML,但是当我把它放在我自己的html中也是行不通的。



如何在此网页末尾嵌入互动式Google趋势图 http://knowyourmeme.com/memes/danbo

解决方案

将Google趋势结果包含在iframe中,然后完成。

 < iframe scrolling =nostyle =border:none; width =640height =330src =http://www.google.com/trends/fetchComponent?hl=zh-CN&q=danbo+robot,danbo+amazon,danbo+yotsuba& cmpt = q&安培;含量= 1&安培; CID = TIMESERIES_GRAPH_0&安培;出口= 5&安培; W = 640安培; H = 330\" >< / iframe中> 

请参阅演示


I saw a site that embedded an interactive Google trend chart on the page: http://knowyourmeme.com/memes/danbo

When I inspected the element, the chart was embedded with the code:

<script type="text/javascript" src="http://www.google.com/trends/embed.js?hl=en-US&amp;q=danbo%20robot,danbo%20amazon,danbo%20yotsuba&amp;content=1&amp;cid=TIMESERIES_GRAPH_0&amp;export=5&amp;w=600&amp;h=350"></script>

I checked the top of the html for google related script and I found these:

<script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-15176568-9'); ga('send', 'pageview'); </script>

<script type="text/javascript"> var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; (function() { var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; gads.src = 'http://www.googletagservices.com/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); googletag.cmd.push(function() { googletag.pubads().setTargeting('site', 'kym'); googletag.pubads().setTargeting('page', '_memes_danbo'); }); </script>

But when i created an html file as such:

<html>

<script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-15176568-9'); ga('send', 'pageview'); </script>

<script type="text/javascript"> var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; (function() { var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; gads.src = 'http://www.googletagservices.com/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); googletag.cmd.push(function() { googletag.pubads().setTargeting('site', 'kym'); googletag.pubads().setTargeting('page', '_memes_danbo'); }); </script>

<script type="text/javascript" src="http://www.google.com/trends/embed.js?hl=en-US&amp;q=danbo%20robot,danbo%20amazon,danbo%20yotsuba&amp;content=1&amp;cid=TIMESERIES_GRAPH_0&amp;export=5&amp;w=600&amp;h=350"></script>

</html>

I did not have the Google trend chart but I didn't get the chart and had this:

When you go to the Google trend site, e.g. http://www.google.com/trends/explore?hl=en-US#q=danbo+robot,danbo+amazon,danbo+yotsuba , there are embedded scripts that one can copy and paste into the html but when i put it in my own html it didn't work too.

How do I embed an interactive Google trend chart like at the end of this webpage http://knowyourmeme.com/memes/danbo ?

解决方案

Include the Google trend result in an iframe and you are done.

<iframe scrolling="no" style="border:none;" width="640" height="330" src="http://www.google.com/trends/fetchComponent?hl=en-US&q=danbo+robot,danbo+amazon,danbo+yotsuba &cmpt=q&content=1&cid=TIMESERIES_GRAPH_0&export=5&w=640&h=330"></iframe>

See Demo

这篇关于如何嵌入谷歌趋势图在HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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