这个javascript事件处理程序做了什么?

时间:2011-06-15 02:39:56

标签: javascript

我试图为表单提交提取事件处理程序。 对于一个网站,我得到了这个非常奇怪的处理程序: 我的问题是这个处理程序做了什么,更重要的是它是一部分 JSLibrary。

以下是该网页的链接: http://www.nfl.com/fantasy/story/09000d5d817fb977/article/nfl.fantasy/story;s1=story;slot=top;url=story;nfl=ad;!category=;kw=;team=no;team=was;team=sd;team=nyg;team=ten;team=bal;conf=nfc;conf=afc;dvsn=ncs;dvsn=nce;dvsn=acw;dvsn=acs;dvsn=acn;plyr=matthew_ryan;plyr=anquan_boldin;plyr=derrick_mason;event=fantasy;tile=

当您尝试单击电子邮件按钮时出现的右上角的电子邮件表单时,会运行处理程序。

function q(a) {
  a = a || window.event;
  var b = a.target || a.srcElement, c, d;
  while (b && b.nodeName.toLowerCase() !== "a") {
      b = b.parentNode;
  }
  if (b && b.nodeName.toLowerCase() === "a" && b.href) {
      c = b.href.match(f);
      if (c) {
          var e = o(b.href);
          twttr.events.hub ? (d = new p(l.generateId(), b), l.add(d), n(e, b), twttr.events.trigger("click", {target:b, region:"intent", type:"click", data:{}})) : m(e), a.returnValue = !1, a.preventDefault && a.preventDefault();
      }
  }

}

1 个答案:

答案 0 :(得分:0)

不,它使用的唯一库是Twitter。其余的是相当简单的JavaScript,虽然变量和函数名称被缩小,因此很难阅读。

function q(a) {
  // Get the event from the passed argument if it exists,
  // otherwise use the current event in the window
  a = a || window.event;

  // Get the target or source of the event, initialize variables c and d
  var b = a.target || a.srcElement, c, d;

  // Keep moving to the parent node of the target until you reach an <a> node
  while (b && b.nodeName.toLowerCase() !== "a") {
      b = b.parentNode;
  }

  // Double-check that b is an <a> node, then that
  // it has an href attribute, making it a link
  if (b && b.nodeName.toLowerCase() === "a" && b.href) {
      // f is unknown, but I assume here it matches the URL in the <a> tag
      // against some regular expression to make sure it's valid
      c = b.href.match(f);
      if (c) {
          // Extract the URL
          var e = o(b.href);

          // Send it on to Twitter if possible, otherwise just cancel
          // the click event
          twttr.events.hub ? (d = new p(l.generateId(), b), l.add(d), n(e, b),
            twttr.events.trigger("click", {target:b, region:"intent",
            type:"click", data:{}})) :
            m(e), a.returnValue = !1,
            a.preventDefault && a.preventDefault();
      }
   }
}
相关问题