1

I use content_scripts in chrome extension to catch the event of opening new site. But when i click on this site a link that redirects me to subsite the event is not fired.

It's not usual site that uses reload to handle link clicks. After clicking link i'm redirected to something like (AJAX?):

http://somesite.com/page#something

So i suppose it's dynamically loaded. How to handle all events of reloading of this page?

How to catch every event of loading page not only by entering into URL field but also by clicking links?

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
Tom Smykowski
  • 25,487
  • 54
  • 159
  • 236
  • 2
    For future reference, you can also use the Chrome Developer Tools to setup a click listener on the element (in "Scripts" tab, on the right panel, scroll down to "Event Listener", expand the "Mouse" section and check the "click" event). This will make the debugger pause on click, and you can check what's actually going on. – Boris Smus Aug 17 '11 at 23:08

1 Answers1

5

You are going to have to hook the mousedown event. With JQuery it looks like this:

$('a').mousedown(function(){
alert($(this).attr('href'));
});

You'll have to examine the value of the href for $(this) and then do whatever you need to do.

Sounds like the page you are working with has frames so you need "all_frames": true in your manifest under the content_scripts section.

mikeazo
  • 389
  • 2
  • 24
Darin
  • 2,071
  • 2
  • 17
  • 14