0

I have a webpage which displays dynamically generated content from another website with lots of hyperlinks.

Clicking on these hyperlinks results in the opening of either a new tab or window - depending on the browser's settings.

Is there any way that I can detect the URL of the page that is opened on the click?

I am thinking I should use Javascript in my own page with a "Body onload" kind of listener.

Any ideas are most welcome.

Thank you in advance.

Uttam

4

1 回答 1

0

如果你使用 jQuery,你可以很容易地做到这一点:

   $(document).on('click', 'a', function () {
      var $anchor = $(this),
          url = $anchor.prop('href');

      // Use the url variable here.

   });

document这将为单击锚点时触发的事件创建和事件处理程序。

于 2013-07-21T00:50:04.983 回答