jQuery find location.href and replace with function
<p>I am turning all page elements from separate loads to Ajax pages if javascript is enabled using jQuery.  I have done most of thing, but one thing I need to check is for onclick/onchange events.  </p>

<p>I have this:</p>

<pre><code>    $("select").each(function(){
        if ($(this).attr('onchange')) {
            //CHECK FOR LOCATION.HREF
        }
        return false;
    });
</code></pre>

<p>and need to change things like:</p>

<pre><code>location.href='/calendar-of-events/'+escape(this.options[this.selectedIndex].value)+'/5/2011/
</code></pre>

<p>into:</p>

<pre><code>pageload('/calendar-of-events/'+escape(this.options[this.selectedIndex].value)+'/5/2011/')
</code></pre>

<p>How would I do that?</p>

<p>Thanks.</p>

<p>EDIT:</p>

<p>I tried:</p>

<pre><code>    $("select").each(function(){
        if ($(this).attr('onchange')) {
            var ocval = $(this).attr('onchange');
            ocval = ocval.replace('location.href=','pageload(');
            ocval = ocval+')';
            $(this).attr('onchange',ocval);
        } 
        return false;
    });
</code></pre>

<p>but that doesn't work.  The onchange value is a function.  </p>

<pre><code>function onchange(event) {
    location.href = "/calendar-of-events/" + escape(this.options[this.selectedIndex].value) + "/5/2011/";
}
</code></pre>

<p>How would I change that?  </p>
