Force re-eval inline and included Javascript
<p>I'm injecting Javascript into a page w/ Greasemonkey, doing some processing on the body content (adding markup) then re-inserting the content. The problem is that all the events in the original content are lost, breaking things like onClick events that were added when the page initially loaded.</p>

<p>My original idea was to do this (using jQuery) to just re-add the script tags to the head:</p>

<pre><code>$('script').each(function(s, script) {  $(script).appendTo('head');  })
</code></pre>

<p>or just:</p>

<pre><code>$('script').appendTo('head');
</code></pre>

<p>I thought this would cause scripts to reload/reeval, but it doesn't work. </p>

<p>A simple example of where I'd like to do this would be on: <a href="http://en.m.wikipedia.org/wiki/John_Hardy_%28song%29" rel="nofollow">http://en.m.wikipedia.org/wiki/John_Hardy_%28song%29</a> I'd need to re-apply the this event found in application.js</p>

<pre><code> $("h2.section_heading").click(function() {
 // Do something
 }) 
</code></pre>
