Any way to apply oncontextmenu and title values to ALL images?

Discussion in 'HTML' started by Chris Tomlinson, Jul 24, 2006.

  1. Hi all, just a quickie. I hope someone has the answer.

    We have about 30 images on a page, and want to apply something like this to
    all of them:

    < ... oncontextmenu="alert('Message here.');return false;" title="Another
    message here." ... >

    We want the same thing copied to every image, which basically makes for
    repetitive, long code that takes more time to load.

    Is there an easy way to have this appear just once in the code, but apply
    itself to all images in the page?
    --
    Thanks,
    Me

    Try Google Quik-e-searchâ„¢ at www.Superhighstreet.com/home
    ....Finds anything or they buy it for you!
     
    Chris Tomlinson, Jul 24, 2006
    #1
    1. Advertising

  2. Chris Tomlinson

    jojo Guest

    Chris Tomlinson wrote:

    > Hi all, just a quickie. I hope someone has the answer.
    >
    > We have about 30 images on a page, and want to apply something like this to
    > all of them:
    >
    > < ... oncontextmenu="alert('Message here.');return false;" title="Another
    > message here." ... >
    >
    > We want the same thing copied to every image, which basically makes for
    > repetitive, long code that takes more time to load.
    >
    > Is there an easy way to have this appear just once in the code, but apply
    > itself to all images in the page?


    If you want to have it applied to the images _after_loading the page you
    have to use JavaScript. I guess you still won't believe that this
    *might* be a problem because many users have it switched off, so it
    shouldn't be a problem to use it. But IMHO it's just ridiculous to strip
    out snippets of the HTML code to get it loaded more quickly and applying
    a JS which takes some time to load...
     
    jojo, Jul 24, 2006
    #2
    1. Advertising

  3. Chris Tomlinson

    Andy Dingley Guest

    Chris Tomlinson wrote:

    > We have about 30 images on a page, and want to apply something like this to
    > all of them:
    >
    > < ... oncontextmenu="alert('Message here.');return false;" title="Another
    > message here." ... >


    Use subroutines, not pages of inline code.

    Write subroutines that are context-intelligent, i.e. they can tell
    which event and DOM node triggered them and react accordingly, they
    don't have to have a squillion parameters passed in through the inline
    event handler call.

    Use event listeners.

    Read any modern book on modern JavaScript techniques (probably one
    blathering about AJAX too)
     
    Andy Dingley, Jul 24, 2006
    #3
  4. "jojo" <> wrote in message
    news:ea2qin$h68$...
    > Chris Tomlinson wrote:
    >
    >> Hi all, just a quickie. I hope someone has the answer.
    >>
    >> We have about 30 images on a page, and want to apply something like this
    >> to all of them:
    >>
    >> < ... oncontextmenu="alert('Message here.');return false;" title="Another
    >> message here." ... >
    >>
    >> We want the same thing copied to every image, which basically makes for
    >> repetitive, long code that takes more time to load.
    >>
    >> Is there an easy way to have this appear just once in the code, but apply
    >> itself to all images in the page?

    >
    > If you want to have it applied to the images _after_loading the page you
    > have to use JavaScript. I guess you still won't believe that this *might*
    > be a problem because many users have it switched off, so it shouldn't be a
    > problem to use it. But IMHO it's just ridiculous to strip out snippets of
    > the HTML code to get it loaded more quickly and applying a JS which takes
    > some time to load...


    Thanks, but if I did want to use JS I notice FF browser ignores it anyway
    and allows right-click, so ideally I was hoping for something HTML only. I
    guess it's not possible but let me know if I'm wrong, thanks.

    --
    Thanks,
    Me

    Try Google Quik-e-searchT at www.Superhighstreet.com/home
    ....Finds anything or they buy it for you!
     
    Chris Tomlinson, Jul 24, 2006
    #4
  5. Chris Tomlinson

    Randy Webb Guest

    Chris Tomlinson posted the following to news:comp.lang.javascrit on
    7/24/2006 1:33 PM:

    [follow-up set to comp.lang.javascript]

    > "jojo" <> wrote in message
    > news:ea2qin$h68$...
    >> Chris Tomlinson wrote:
    >>
    >>> Hi all, just a quickie. I hope someone has the answer.
    >>>
    >>> We have about 30 images on a page, and want to apply something like this
    >>> to all of them:
    >>>
    >>> < ... oncontextmenu="alert('Message here.');return false;" title="Another
    >>> message here." ... >
    >>>
    >>> We want the same thing copied to every image, which basically makes for
    >>> repetitive, long code that takes more time to load.
    >>>
    >>> Is there an easy way to have this appear just once in the code, but apply
    >>> itself to all images in the page?

    >> If you want to have it applied to the images _after_loading the page you
    >> have to use JavaScript. I guess you still won't believe that this *might*
    >> be a problem because many users have it switched off, so it shouldn't be a
    >> problem to use it. But IMHO it's just ridiculous to strip out snippets of
    >> the HTML code to get it loaded more quickly and applying a JS which takes
    >> some time to load...

    >
    > Thanks, but if I did want to use JS I notice FF browser ignores it anyway
    > and allows right-click,


    That's because FF ignores the oncontextmenu, whether initiated by script
    or by HTML code.

    > so ideally I was hoping for something HTML only.


    It still won't do what you want, test it in Opera.

    > I guess it's not possible but let me know if I'm wrong, thanks.


    You aren't wrong, it's impossible to reliably change the contextmenu.

    Guess: You don't want your images copied and you think this is the way
    to do that.
    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Jul 24, 2006
    #5
  6. Chris Tomlinson

    Randy Webb Guest

    jojo said the following on 7/24/2006 4:00 PM:
    > Randy Webb schrieb:
    >> Chris Tomlinson posted the following to news:comp.lang.javascript on
    >> 7/24/2006 1:33 PM:


    <snip>

    >>> I guess it's not possible but let me know if I'm wrong, thanks.

    >>
    >> You aren't wrong, it's impossible to reliably change the contextmenu.
    >>
    >> Guess: You don't want your images copied and you think this is the way
    >> to do that.

    >
    > I hope you don't still believe that - a few people told you in your last
    > threat (specify loading order of JPGs) that there is no way to protect
    > your images cause they are already saved in the browser's cache when you
    > view the page...


    Yooooohoooooo, do you have any concept of who you are replying to and
    the context of what you posted?

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Jul 24, 2006
    #6
  7. Chris Tomlinson

    jojo Guest

    Randy Webb wrote:

    > <snip>
    >
    >>>> I guess it's not possible but let me know if I'm wrong, thanks.
    >>>
    >>> You aren't wrong, it's impossible to reliably change the contextmenu.
    >>>
    >>> Guess: You don't want your images copied and you think this is the
    >>> way to do that.

    >>
    >> I hope you don't still believe that - a few people told you in your
    >> last threat (specify loading order of JPGs) that there is no way to
    >> protect your images cause they are already saved in the browser's
    >> cache when you view the page...

    >
    > Yooooohoooooo, do you have any concept of who you are replying to and
    > the context of what you posted?
    >

    I have... But I guess Chris will read this, too, so I talked to him (No,
    Randy, you are not the "you" in my last post, forgive me if that was not
    clear). I just took over the "you" you were replying to in your post.

    And yes, I know about the context. I'm just trying to convince Chris of
    leaving out all the "oncontextmenu"s cause they just cause errors and
    help nothing. But many people have tried this before - with no success.
     
    jojo, Jul 24, 2006
    #7
  8. "jojo" <> wrote in message
    news:ea3ajl$3dk$...
    > Randy Webb wrote:
    >
    >> <snip>
    >>
    >>>>> I guess it's not possible but let me know if I'm wrong, thanks.
    >>>>
    >>>> You aren't wrong, it's impossible to reliably change the contextmenu.
    >>>>
    >>>> Guess: You don't want your images copied and you think this is the way
    >>>> to do that.
    >>>
    >>> I hope you don't still believe that - a few people told you in your last
    >>> threat (specify loading order of JPGs) that there is no way to protect
    >>> your images cause they are already saved in the browser's cache when you
    >>> view the page...

    >>
    >> Yooooohoooooo, do you have any concept of who you are replying to and the
    >> context of what you posted?
    >>

    > I have... But I guess Chris will read this, too, so I talked to him (No,
    > Randy, you are not the "you" in my last post, forgive me if that was not
    > clear). I just took over the "you" you were replying to in your post.
    >
    > And yes, I know about the context. I'm just trying to convince Chris of
    > leaving out all the "oncontextmenu"s cause they just cause errors and help
    > nothing. But many people have tried this before - with no success.


    No guys, it's not to protect the images, it's just a deterrent and to
    display a copyright notice. I'm aware of the fact it doesn't work in Opera.
    It's a deterrent for the most popular browsers.
    --
    Thanks,
    Me

    Try Google Quik-e-searchT at www.Superhighstreet.com/home
    ....Finds anything or they buy it for you!
     
    Chris Tomlinson, Jul 24, 2006
    #8
  9. Chris Tomlinson wrote:

    > No guys, it's not to protect the images, it's just a deterrent and to
    > display a copyright notice. I'm aware of the fact it doesn't work in Opera.
    > It's a deterrent for the most popular browsers.


    Browser(s)? you mean *browser*, IE only.


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Jul 24, 2006
    #9
  10. Chris Tomlinson

    Randy Webb Guest

    Chris Tomlinson said the following on 7/24/2006 5:06 PM:
    > "jojo" <> wrote in message
    > news:ea3ajl$3dk$...
    >> Randy Webb wrote:
    >>
    >>> <snip>
    >>>
    >>>>>> I guess it's not possible but let me know if I'm wrong, thanks.
    >>>>> You aren't wrong, it's impossible to reliably change the contextmenu.
    >>>>>
    >>>>> Guess: You don't want your images copied and you think this is the way
    >>>>> to do that.
    >>>> I hope you don't still believe that - a few people told you in your last
    >>>> threat (specify loading order of JPGs) that there is no way to protect
    >>>> your images cause they are already saved in the browser's cache when you
    >>>> view the page...
    >>> Yooooohoooooo, do you have any concept of who you are replying to and the
    >>> context of what you posted?
    >>>

    >> I have... But I guess Chris will read this, too, so I talked to him (No,
    >> Randy, you are not the "you" in my last post, forgive me if that was not
    >> clear). I just took over the "you" you were replying to in your post.
    >>
    >> And yes, I know about the context. I'm just trying to convince Chris of
    >> leaving out all the "oncontextmenu"s cause they just cause errors and help
    >> nothing. But many people have tried this before - with no success.

    >
    > No guys, it's not to protect the images, it's just a deterrent


    A "deterrent" to what? Surely not image theft because that would prove
    my point.

    > and to display a copyright notice.


    Then display it on the page. Then it is always seen.

    > I'm aware of the fact it doesn't work in Opera.


    So you admit to trying to do something that isn't going to work?

    > It's a deterrent for the most popular browsers.


    It's not even that and if you think it is, you are more naive than you
    appear.
    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Jul 25, 2006
    #10
    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. Andreas Klemt
    Replies:
    1
    Views:
    494
    Steve C. Orr, MCSD
    Aug 10, 2003
  2. Stefan Siegl
    Replies:
    1
    Views:
    994
    Marrow
    Jul 18, 2003
  3. Terri I.
    Replies:
    0
    Views:
    120
    Terri I.
    Aug 13, 2003
  4. Chris Tomlinson
    Replies:
    10
    Views:
    194
    BootNic
    Jul 25, 2006
  5. Charlie
    Replies:
    1
    Views:
    89
Loading...

Share This Page