title: Dealing with `return false` when using `eval`in JavaScript
body: <p>I'm dealing with a situation where I need to bind jQuery events to a page to handle UI updates that is being generated via JSF. Alas, JSF sucks and it sticks onclick events on everything, which pre-empt any of my jQuery work.</p>
  
  <p>Thanks to the fine folks here on SO, I found a solution for that:</p>
  
  <p><a href="https://stackoverflow.com/questions/7507861/mixing-my-jquery-click-events-with-existing-objects-onclick-attribute">mixing my jQuery click events with existing object&#39;s onclick attribute</a></p>
  
  <p>The logic is:</p>
  
  <ul>
  <li>on page load, grab all of the <code>onclick</code> attributes and store them in a variable.</li>
  <li>bind my jQuery events</li>
  <li>after my own jQuery events, I can then <code>eval</code> the original onclick: <code>eval(onclickValueVariable)</code></li>
  </ul>
  
  <p>This worked find in all my dummy onclick event testing. </p>
  
  <p>But then it failed on that live JSF page. The issue is that all of the onclick's end with a 'return false' which leads to this error:</p>
  
  <pre><code>return not in function
  </code></pre>
  
  <p>For example:</p>
  
  <pre><code>&lt;div class="uglyJSFcreatedTag" onclick="console.log('hey');return false"&gt;
  </code></pre>
  
  <p>And the jQuery that would fire it:</p>
  
  <pre><code>var $jsfTag = $('.uglyJSFcreatedTag');
  var cacheOnclick = $jsfTag.attr(onclick);
  $jsfTag.removeAttr('onclick');
  
  ...bunch of logic here to decide if the inline onclick should fire and, if so...
  
  eval(cacheOnclick)
  </code></pre>
  
  <p>The problem is the <code>return false</code>. It looks like nothing can be returned when firing a eval.</p>
  
  <p>Is there a solution for this? I imagine I could take the value as a string and do string parsing to remove all return false, then call that from the script itself. But that sounds a bit messy. Is there a more elegant solution?</p>
  
  <p>If not, what particular JS statements should I be looking for to filter out before calling <code>eval</code>?</p>