将对象发送到远程 javascript 文件
因此,如果我在我的网站上设置雅虎管道徽章,雅虎会给我这段代码,
<script src="http://pipes.yahoo.com/js/listbadge.js">{"pipe_id":"USER_ID","_btype":"list"}</script>
请注意它将对象文字传递给远程脚本。 我想用我自己的脚本做类似的事情,你如何与该输入交互?
So if i am setting up a yahoo pipes badge on my site, yahoo gives me this code
<script src="http://pipes.yahoo.com/js/listbadge.js">{"pipe_id":"USER_ID","_btype":"list"}</script>
Notice its passing an object literal to the remote script.
i would like to do something similar with my own scripts, how do you interact with that input?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,您无法像本机那样传递变量。 雅虎正在做的是,在他们的 listbadge.js 文件中,它搜索页面上的所有
标记,直到找到包含它的标记,然后将 innerHTML 解析为 JSON 。
他们的来源有点混乱,但这是我对其的最好理解。
You can't actually pass variables around like that natively. What Yahoo is doing there is that in their listbadge.js file, it searches through all the
<script>
tags on the page until it finds the one which included it, and then parses the innerHTML as JSON.Their source has been slightly obfuscated, but here's my best understanding of it.