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

C

Chris Tomlinson

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!
 
J

jojo

Chris said:
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...
 
A

Andy Dingley

Chris said:
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)
 
C

Chris Tomlinson

jojo said:
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!
 
R

Randy Webb

Chris Tomlinson posted the following to on
7/24/2006 1:33 PM:

[follow-up set to comp.lang.javascript]
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.
 
R

Randy Webb

jojo said the following on 7/24/2006 4:00 PM:
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?
 
J

jojo

Randy said:
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.
 
C

Chris Tomlinson

jojo said:
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!
 
J

Jonathan N. Little

Chris said:
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.
 
R

Randy Webb

Chris Tomlinson said the following on 7/24/2006 5:06 PM:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top