Is there a simple way to include a remote js file on the fly (in an onclick function)?
The "verify" onc开发者_Go百科lick 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.
If 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.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS
精彩评论