[英]How to add external javascript library and stylesheets in a widget?
I am trying to create a Javascript widget where in the user of the widget will have to add a couple of lines of Javascript to his page which in turn will add an externally hosted javascript to his page. 我正在尝试创建一个Javascript小部件,其中小部件的用户必须在其页面中添加几行Javascript,这又将在其页面中添加外部托管的javascript。 Through this javascript, I'll add HTML code to his page. 通过此javascript,我将HTML代码添加到他的页面。 In this HTML, I'm using Angular Material Library. 在此HTML中,我正在使用Angular Material Library。
I have a few questions: 我有几个问题:
You are most likely to create an iframe solution which your Javascript will inject on the page upon rendering. 您最有可能创建一个iframe解决方案,您的Javascript将在呈现时注入到页面上。
Name conflicts can be avoided using naming convention for stylesheets, IIFE for scoping. 使用样式表的命名约定,使用范围的IIFE可以避免名称冲突。
I think your question seems already answered here: Creating a javascript widget for other sites 我认为您的问题似乎已经在这里得到了解答: 为其他网站创建javascript小部件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.