jquery - Prevent onclick and retrieve parameters of function call
<p>We've been asked to put in a band-aid measure to some code so this is going to look really dumb but bear with me.</p>

<p>We need to prevent an onclick method of an anchor and retrieve the parameters of the function call being made in order to call a different function with those parameters.
Here is the code and html we have so far:</p>

<pre><code>&lt;p&gt;&lt;a href="#" onclick="openMoreProductVideos('Title of video','VideoCode','false');return false;"&gt;&lt;span class="txt"&gt;View all videos&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
</code></pre>

<p>JS:</p>

<pre><code>// undefine onclick so it is not handled with broken function
$('a[onClick^=openMoreProductVideos]').each(function () {
    this.onclick = undefined;   
});

    // grab parameters from onclick function call and submit to new function.
$('a[onClick^=openMoreProductVideos]').click(function () {
    strStart = "openMoreProductVideos(";
    strFinish = ");return false"
    srctext = $(this).parent().html();      
    var re = strStart + ".*?"+strFinish
    var newtext = srctext.match(re)[1];
    var callparams = newtext.substring(1,newtext.length-1);
    testparams(callparams);
  });

 // test function to see if parameters are working
 function testparams (a,b,c){
    console.log (a,b,c)
 }
</code></pre>

<p>Problem is that the returned string (callparams) is seen as one parameter.  I am not a regex expert so I'm hoping that someone with more experience than I can quickly see the solution.</p>

<p>Many thanks.</p>
