Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Any way to apply oncontextmenu and title values to ALL images?

Reply
Thread Tools

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

 
 
Chris Tomlinson
Guest
Posts: n/a
 
      07-24-2006
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!


 
Reply With Quote
 
 
 
 
jojo
Guest
Posts: n/a
 
      07-24-2006
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...
 
Reply With Quote
 
 
 
 
Andy Dingley
Guest
Posts: n/a
 
      07-24-2006
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)

 
Reply With Quote
 
Chris Tomlinson
Guest
Posts: n/a
 
      07-24-2006
"jojo" <(E-Mail Removed)> wrote in message
news:ea2qin$h68$(E-Mail Removed)...
> 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!


 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      07-24-2006
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" <(E-Mail Removed)> wrote in message
> news:ea2qin$h68$(E-Mail Removed)...
>> 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/
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      07-24-2006
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/
 
Reply With Quote
 
jojo
Guest
Posts: n/a
 
      07-24-2006
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.
 
Reply With Quote
 
Chris Tomlinson
Guest
Posts: n/a
 
      07-24-2006
"jojo" <(E-Mail Removed)> wrote in message
news:ea3ajl$3dk$(E-Mail Removed)...
> 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!


 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      07-24-2006
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
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      07-24-2006
Chris Tomlinson said the following on 7/24/2006 5:06 PM:
> "jojo" <(E-Mail Removed)> wrote in message
> news:ea3ajl$3dk$(E-Mail Removed)...
>> 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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
oncontextmenu and preventDefault for right clicks in Firefox Charlie Javascript 1 01-23-2007 11:11 AM
Any way to apply oncontextmenu and title values to ALL images? Chris Tomlinson Javascript 10 07-25-2006 12:19 AM
Using both onmouseup and oncontextmenu events Terri I. Javascript 0 08-13-2003 08:10 PM
Fastest way to get a the string between <title> </title> Andreas Klemt ASP .Net 1 08-10-2003 01:58 AM
[XSLT] could not apply "apply-templates" Stefan Siegl XML 1 07-18-2003 09:43 AM



Advertisments