开发者

Link to function instead of website

开发者 https://www.devze.com 2023-01-25 18:53 出处:网络
I have made a contentscript which \"injects\" the following into a website: < a href=\"somewebsite.html\">mytext< /a>

I have made a contentscript which "injects" the following into a website:

< a href="somewebsite.html">mytext< /a>

The trouble I'm facing is th开发者_开发问答at I want to link it to a function in my chrome extension instead. Something like:

< a href="mychromeextensionfunction">mytext< /a>.

How would I manage to do that, Is it even possible to link to a chrome extension function?


You can't do that through the href attribute; you need the onClick attribute.


That explains it, Thanks for putting me in the right direction : )

Here's a sample code of how you could do it.

link_dom.onclick=function (evt) { alert('hello'); }

0

精彩评论

暂无评论...
验证码 换一张
取 消