javascript - How to send an alert in chrome extensions? - Stack Overflow

I am trying to get some experience with chrome extensions. I have a question though. Let's say I a

I am trying to get some experience with chrome extensions. I have a question though. Let's say I am writing an extension that everytime you see the word (wow) in the url, i will alert the user with a red page that they have to click on accept to pass, or an alert box that they have to get through in order to see the page, how would i:

1) get the url of the page 2) make the red alerting page, or the alert box without the need for the user to actually go click at the extension's icon to get information?

Thank you so much

I am trying to get some experience with chrome extensions. I have a question though. Let's say I am writing an extension that everytime you see the word (wow) in the url, i will alert the user with a red page that they have to click on accept to pass, or an alert box that they have to get through in order to see the page, how would i:

1) get the url of the page 2) make the red alerting page, or the alert box without the need for the user to actually go click at the extension's icon to get information?

Thank you so much

Share Improve this question edited Jan 14, 2013 at 13:40 Eonasdan 7,7939 gold badges60 silver badges85 bronze badges asked Jan 14, 2010 at 5:04 user220755user220755 4,44616 gold badges55 silver badges71 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

It's certainly late, but I thought I'd answer anyway. What you need is a content script. You can set it to match on certain domains and then do a more granular filter inside the script checking against window.location and alerting/displaying a div layer for matched URLs. The content script has full access to the page DOM so you can easily hide or dim it and show a warning.

Can also be done using chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){})... API. One can find if(tab.url.indexOf("www.wow.") > -1){ //do things here }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745251914a4618727.html

相关推荐

  • javascript - How to send an alert in chrome extensions? - Stack Overflow

    I am trying to get some experience with chrome extensions. I have a question though. Let's say I a

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信