I've got a script that inserts some content into an element using The content could for example be: Problem is that the code inside the Has anyone got a snippet of code that executes all the Edit: By peeking into the jQuery code I've managed to figure out how jQuery does it, which resulted in the following code: | |||||||||||||||||||||
|
| The OP's script doesn't work in IE 7. With help from SO, here's a script that does: | |||||||||||||||||||||
|
| @phidah... Here is a very interesting solution to your problem:http://24ways.org/2005/have-your-dom-and-script-it-too So it would look like this instead:
| |||||||||||||
|
| Try this snippet: | |||
| Here's a shorter, more efficient script that also works for scripts with the Note: whilst | |||||||||||||||||||||
|
| You should not use the innerHTML property but rather the appendChild method of the Node: a node in a document tree [HTML DOM]. This way you are able to later call your injected code. Make sure that you understand that Sample injection works: regards, | |||||||||
|
It works in Chrome in my project | |||||
|
|
| |||||
|
| A solution without using "eval": This essentially clones the script tag and then replaces the blocked script tag with the newly generated one, thus allowing execution. | |||
| It's easier to use jquery This also works with scripts that use | |||
| You may take a look at this post. The code might look like this: | |||
| Thanks to Larry's script, which worked perfectly well in IE10, this is what I've used: | ||||
| Try function eval(). This is a real example from a project that i am developing.Thanks to this post | ||||
| Extending off of Larry's. I made it recursively search the entire block and children nodes. | |||
| Try this, it works for me on Chrome, Safari & Firefox: One thing to note though, is that the following div-nested script will NOT run: For a script to run it has to be created as a node then appended as a child. You can even append a script inside a previously injected div & it will run (I've run into this before when trying to get ad server code to work): | ||||
| Just do: | |||||||||
|


