感谢您的快速回复。 我想根据谷歌搜索结果跟踪链接。
在某些情况下,它适用于正常但不适用于Google搜索结果的链接,例如https:// www.google.com.vn /?gws_rd = ssl#q = google + adwords。
我将尝试逐步重现问题:
1.使用handle事件安装插件,单击以下代码。
function handleWindowClick(event) {
var origEl = event.target;
if(origEl.tagName == 'A') {
// do some things with event link: origEl.toString();
alert("Event Link: " + origEl.toString());
} else if(origEl.parentNode.tagName == 'A') {
alert("Event Link: " + origEl.parentNode.toString());
} else if(origEl.tagName == 'SPAN') {
alert("Span is clicked");
}
}
window.addEventListener('click', handleWindowClick, false);
答案 0 :(得分:0)
根据您编辑的代码进行更新:
function handleWindowClick(event) {
var origEl = event.target;
if(origEl.tagName == 'A') {
// do some things with event link: origEl.toString();
alert("Event Link: " + origEl.toString());
} else if(origEl.parentNode.tagName == 'A') {
alert("Event Link: " + origEl.parentNode.toString());
} else if(origEl.tagName == 'SPAN') {
alert("Span is clicked");
}
}
window.addEventListener('click', handleWindowClick, false);
ps:投票关闭你话题的人感到羞耻,只因为你不能很好地输入英语。