script-tag

How to force a script reload and re-execute?

…衆ロ難τιáo~ 提交于 2019-11-26 11:45:38
I have a page that is loading a script from a third party (news feed). The src url for the script is assigned dynamically on load up (per third party code). <div id="div1287"> <!-- dynamically-generated elements will go here. --> </div> <script id="script0348710783" type="javascript/text"> </script> <script type="javascript/text"> document.getElementById('script0348710783').src='http://oneBigHairyURL'; </script> The script loaded from http://oneBigHairyURL then creates and loads elements with the various stuff from the news feed, with pretty formatting, etc. into div1287 (the Id "div1287" is

How can I read a JSON in the script-tag from JavaScript?

北城以北 提交于 2019-11-26 10:30:04
问题 I have a dynamically generated page where I want to use a static JavaScript and pass it a JSON string as a parameter. I have seen this approach used by Google (see Google\'s +1 Button: How do they do it?). But how should I read the JSON string from the JavaScript? <html> <head> <script src=\"jquery-1.6.2.min.js\"></script> <script src=\"myscript.js\">{\"org\": 10, \"items\":[\"one\",\"two\"]}</script> </head> <body> Hello </body> </html> In this JavaScript I would like to use the JSON

React: Script tag not working when inserted using dangerouslySetInnerHTML

吃可爱长大的小学妹 提交于 2019-11-26 08:27:28
问题 I\'m trying to set html sent from my server to show inside a div using dangerouslySetInnerHTML property in React. I also have script tag inside it and use functions defined in same inside that html. I have made example of error in JSFiddle here. This is test code: var x = \'<html><scr\'+\'ipt>alert(\"this.is.sparta\");function pClicked() {console.log(\"p is clicked\");}</scr\'+\'ipt><body><p onClick=\"pClicked()\">Hello</p></body></html>\'; var Hello = React.createClass({ displayName: \'Hello

How to dynamically insert a <script> tag via jQuery after page load?

不羁的心 提交于 2019-11-26 07:31:48
I'm having problems getting this to work. I first tried setting my script tags as strings and then using jquery replaceWith() to add them to the document after page load: var a = '<script type="text/javascript">some script here</script>'; $('#someelement').replaceWith(a); But I got string literal errors on that var. I then tried encoding the string like: var a = '&left;script type="text/javascript">some script here<\/script>'; but sending that to replaceWith() outputs just that string to the browser. Can someone please let me know how you would go about dynamically adding a <script> tag into