SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast Nick Karpov's Avatar
    Join Date
    Jan 2007
    Location
    Toronto Ontario
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Little JS help for firefox extension

    This might be more of a firefox extension development question but it has to do with JS so i'll ask here in hopes of finding someone with experience in this.

    My extension requires the URL of the image that was right clicked. Meaning I have added a new option in the right-click menu when an image is right-clicked that calls a function in my JS file

    Code JavaScript:
    imgSrc ();

    This function requires the URL of the image that was right clicked to be passed into it. Does anyone know how I would do that?

    Hopefully someone with experience in Firefox extension creation can help me out.

    Thanks a lot,

    Nick

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    With Javascript you use im.getAttribute('src') where im is a reference to the image element in question. If it's being clicked there will be an event happening so I suppose you'll be doing something like this:
    Code:
    im.onclick = imgSrc; // im is a reference to the IMG element
    
    function imgSrc() {
      var src = this.getAttribute('src');
      // do stuff with src
    }

  3. #3
    SitePoint Enthusiast Nick Karpov's Avatar
    Join Date
    Jan 2007
    Location
    Toronto Ontario
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks Raffles, unfortunately I'm looking for that very event object you're talking about and how to use it, and incorporate it. That's what I can't seem to find ?_?

    Surely someone must have experience with this


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •