Add an onclick attribute to a link tag using Greasemonkey

I have an internal website that has a link with NO `onClick` attribute present. I want to add an `onclick` attribute with a function as the value, like so: onClick="LinkTracker();return true" So that I get a call to the function, but the link click is still followed by the browser. I tried: item.onclick=Function("LinkTracker();return true"); I also tried just a simple function with no return info, and that function was never called either. When I inspect the link element with Firebug, I do not see the `onclick` attribute set. I DO see the `href` value (which I changed) properly updated. Any clues?

以上就是Add an onclick attribute to a link tag using Greasemonkey的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准