title: jQuery: this.attr() not a function?
body: <p>I'm not quite sure if I'm not using this in the correct scope or what, but I have a script that basically captures a link click and causes the page to fade out before going to the linked page. However, if the link is a JavaScript <em>onclick</em>, the script fails.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      pageObj = {
          init: function(){
              $("body").fadeTo("slow", 1);
          },
          redirectPage: function(redirect){
              window.location = redirect;
          },
          linkLoad: function(location){
              $("body").fadeOut(1000, this.redirectPage(location));
          }
      };
  
      $(document).ready(function() {
          pageObj.init();
  
          $("a").click(function(e){
              e.preventDefault();
              if (this.attr('onclick') !== undefined) {
                  eval(this.attr('onclick').val());
              } else {
                  var location = this.href;
                  pageObj.linkLoad(location);
              }
          });
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p><br>
  As you can see, I'm trying to do a check to see if the link has the <em>onclick</em> attribute, and then call the <em>onclick</em> function if it exists. How can I achieve this?</p>