如何解决这个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,twttr.events.trigger(\"click\",{target:b,region:\"intent\",type:\"click\",data:{}})) : m(e),a.returnValue = !1,a.preventDefault && a.preventDefault();
}
}
}
解决方法
不,它使用的唯一库是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,twttr.events.trigger(\"click\",{target:b,region:\"intent\",type:\"click\",data:{}})) :
m(e),a.returnValue = !1,a.preventDefault && a.preventDefault();
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。