I have this fairly simple function that I want to call with onclick="". No matter what I do, I get the error Function is not defined.
html:
<a href="#" onclick="shareURL(); return false;" data-share="https://www.facebook.com/sharer/sharer.php?u=" href="#">Share on Facebook</a>
js:
function shareURL() {
  var $url = window.location.href;
  var $src = $(this).data("share");
  $url = encodeURI($url);
  if ($src) {
    window.location.href = $url + $src;
  }
}
The function resides inside document ready, like in this Fiddle.
 
    