我看到了一个在页面上嵌入了交互式Google趋势图的网站:http://knowyourmeme.com/memes/danbo
当我检查元素时,图表中嵌入了以下代码:
<script type="text/javascript" src="http://www.google.com/trends/embed.js?hl=en-US&q=danbo%20robot,danbo%20amazon,danbo%20yotsuba&content=1&cid=TIMESERIES_GRAPH_0&export=5&w=600&h=350"></script>
我在html的顶部检查了与Google相关的脚本,发现了以下这些内容:
<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>
但是当我这样创建一个html文件时:
<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&q=danbo%20robot,danbo%20amazon,danbo%20yotsuba&content=1&cid=TIMESERIES_GRAPH_0&export=5&w=600&h=350"></script>
</html>
我没有Google趋势图,但没有得到该图,并具有以下功能:
当您访问Google趋势网站时,例如http://www.google.com/trends/explore?hl=zh-CN#q=danbo+robot、danbo+amazon、danbo+yotsuba,其中有一个嵌入式脚本可以复制并粘贴到html中,但是当我将其放在自己的html中时,它也无法正常工作。
我如何嵌入交互式Google趋势图(如本网页结尾处的 http://knowyourmeme.com/memes/danbo所示)?
在iframe中加入Google趋势结果,您就完成了。
<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>
观看演示
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句