how to determine a click on a link

Discussion in 'Javascript' started by yusuf, Jun 30, 2006.

  1. yusuf

    yusuf Guest

    Hi,

    I am writing a greasemonkey script and I can capture the click event.
    What I want to know is how do I determine that the click was on a URL
    and not just a normal click. Thanks.

    document.addEventListener('click', function(event) {
    // event.target is the element that was clicked



    alert(event.target.toString());

    }, true);
    yusuf, Jun 30, 2006
    #1
    1. Advertising

  2. yusuf

    Hal Rosser Guest

    Try adding an event handler to the element. onclick="yourfunction()"

    "yusuf" <> wrote in message
    news:...
    > Hi,
    >
    > I am writing a greasemonkey script and I can capture the click event.
    > What I want to know is how do I determine that the click was on a URL
    > and not just a normal click. Thanks.
    >
    > document.addEventListener('click', function(event) {
    > // event.target is the element that was clicked
    >
    >
    >
    > alert(event.target.toString());
    >
    > }, true);
    >
    Hal Rosser, Jul 1, 2006
    #2
    1. Advertising

  3. yusuf

    yusuf Guest

    i need this to work with every URL on the page, so it would be more
    efficient if i didn't need to rewrite all the links... thanks.

    Hal Rosser wrote:
    > Try adding an event handler to the element. onclick="yourfunction()"
    >
    > "yusuf" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I am writing a greasemonkey script and I can capture the click event.
    > > What I want to know is how do I determine that the click was on a URL
    > > and not just a normal click. Thanks.
    > >
    > > document.addEventListener('click', function(event) {
    > > // event.target is the element that was clicked
    > >
    > >
    > >
    > > alert(event.target.toString());
    > >
    > > }, true);
    > >
    yusuf, Jul 1, 2006
    #3
  4. yusuf

    Hal Rosser Guest

    ok - write a little program that adds the event handler (rewrites the page)
    or for that matter, you could bring it into Word and do a simple
    find/replace.
    === rewriting all the links is easier than rewriting half of them.

    "yusuf" <> wrote in message
    news:...
    >i need this to work with every URL on the page, so it would be more
    > efficient if i didn't need to rewrite all the links... thanks.
    Hal Rosser, Jul 1, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    815
    Kevin Spencer
    May 17, 2005
  2. Replies:
    1
    Views:
    530
  3. Peña, Botp
    Replies:
    1
    Views:
    231
    Robert Klemme
    Jan 24, 2004
  4. Blue®
    Replies:
    4
    Views:
    794
    Blue®
    Sep 27, 2003
  5. Peter Michaux

    Synthetic click on link doesn't follow link

    Peter Michaux, Jun 4, 2007, in forum: Javascript
    Replies:
    2
    Views:
    170
    -Lost
    Jun 5, 2007
Loading...

Share This Page