在AMP页面中添加Javascript [英] Add Javascript in AMP Pages

查看:145
本文介绍了在AMP页面中添加Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我了解如何在AMP(加速移动页面)中添加javascript。我的要求是我在URL中获取ID。例如localhost:8080 / home?id = 1.我想在我的html文件中访问该ID。

Please help me understand how to add javascript in the AMP (Accelerated Mobile Pages). My requirement is I get an ID in URL. For example localhost:8080/home?id=1.I would like to access that id in my html file.

或者请告诉我如何添加任何javascript文件。

or else please let me know how to add any javascript file.

谢谢。

推荐答案

不幸的是,你无法添加AMP中的任意脚本。来自规范的HTML标签下的标签脚本

Unfortunately, you cannot add arbitrary scripts in AMP. From the specification, under "HTML Tags," for the tag script:


除非类型为 application / ld + json 。 (可以根据需要添加其他非可执行值。)例外是加载AMP运行时的必需脚本标记和加载扩展组件的脚本标记。

Prohibited unless the type is application/ld+json. (Other non-executable values may be added as needed.) Exception is the mandatory script tag to load the AMP runtime and the script tags to load extended components.

因此,如果您想使用AMP的JavaScript,您必须使用AMP的预定义组件的。我没有看到一个组件可以满足您的需求。

So, if you want to use JavaScript from AMP, you have to use AMP's predefined components. I don't see a component that does what you want.

这篇关于在AMP页面中添加Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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