admin管理员组文章数量:1332339
Is there a simple way to include a remote js file on the fly (in an onclick function)?
The "verify" onclick event for our ssl site seal requires a code include from the vendor. Trouble is, it slows loads times. So I extracted the function from their js and hosted it locally - but they change the request params from time to time so I have to manually edit the js.
It would be nicer if I could just include the remote file when someone clicks the site seal.
TIA.
Is there a simple way to include a remote js file on the fly (in an onclick function)?
The "verify" onclick event for our ssl site seal requires a code include from the vendor. Trouble is, it slows loads times. So I extracted the function from their js and hosted it locally - but they change the request params from time to time so I have to manually edit the js.
It would be nicer if I could just include the remote file when someone clicks the site seal.
TIA.
Share Improve this question asked May 6, 2011 at 11:54 nedge2knedge2k 1092 silver badges9 bronze badges 1- 1 possible duplicate of How do I load a javascript file dynamically? – Felix Kling Commented May 6, 2011 at 12:00
2 Answers
Reset to default 3If you are using jQuery you can use $.getScript
Description: Load a JavaScript file from the server using a GET HTTP request, then execute it.
You can use the createElement()
and add it to the DOM. Please see the below document.
http://www.hunlock./blogs/Howto_Dynamically_Insert_Javascript_And_CSS
本文标签: javascriptInclude remote js file on the flyStack Overflow
版权声明:本文标题:javascript - Include remote js file on the fly? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742324817a2453512.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论