473,809 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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!
Jul 24 '06 #1
10 2103
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...
Jul 24 '06 #2
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)

Jul 24 '06 #3
"jojo" <jo*********@gm x.dewrote in message
news:ea******** **@registered.m otzarella.org.. .
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!
Jul 24 '06 #4
Randy Webb schrieb:
Chris Tomlinson posted the following to news:comp.lang. javascrit on
7/24/2006 1:33 PM:

[follow-up set to comp.lang.javas cript]
>"jojo" <jo*********@gm x.dewrote in message
news:ea******* ***@registered. motzarella.org. ..
>>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="Anoth er 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.
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...
Jul 24 '06 #5
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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 24 '06 #6
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.
Jul 24 '06 #7
"jojo" <jo*********@gm x.dewrote in message
news:ea******** **@registered.m otzarella.org.. .
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...

Yooooohooooo o, 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!
Jul 24 '06 #8
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
Jul 24 '06 #9
Chris Tomlinson said the following on 7/24/2006 5:06 PM:
"jojo" <jo*********@gm x.dewrote in message
news:ea******** **@registered.m otzarella.org.. .
>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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 24 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2815
by: Stefan Siegl | last post by:
Hello, I am trying to learn XSLT to use it in another project. I start reading the book "Java and XSLT" and tried the examples and they are went quite fine (how suprising *g*). Then I tried to adopt these examples to my files. Unfortunately I did not work even though the styleSheet is very simple. Perhaps you can help me with it.
4
6016
by: Cyrille \cns\ Szymanski | last post by:
Hello, I have a XML document which is typically : <course> <section> <title>Foo</title> There comes the text </section> <section>
4
7622
by: Thomas | last post by:
Hi there, I have an iframe which is editable (designMode = "on") and want to resize it dynamically as the content grows (e.g. more lines of text is in there) and there the struggle starts. I fill the iframe with content (<body> tag and so on and also insert a <div> tag, inbetween is the content that should be modified). Now if the event "overflow" or "underflow" is triggered the iframe
6
3545
by: Olly | last post by:
I've found a basic script, however I also need to add alt and title attributes as well, how would I go about doing this? Here's the script I found: Thanks <script language="JavaScript"> <!-- /*
1
3949
by: ItsMillerTime4u | last post by:
I'm trying to change the <body> 's event oncontextmenu attributes, but am having no luck at it. I know I can do <body oncontextmenu="contextMenu(); return false;"> but the thing is that I set's this attribute as soon as the page loads......which I don't to happen....I don't want to the context menu visible until the page is done loading, and within the window onLoad event I have a vbscript subroutine that connects to a database to pull...
8
10664
by: Lian | last post by:
Hi all, It is a newbie's question about html tag "img". The attributes "title" and "alt" for "img" seems having the same function. So what is the main difference between them? Can i use them at the same time and set different values? Thank you for suggestions!
14
4618
by: Del Ferguson | last post by:
Group, New to this list. I just found out that FireFox does not display the img alt attribute the same way IE does. I use both browsers to verify that my pages are readable. Dumb me for not reading all of the reference document. With this is mind, I need a way to display text in a title attribute, dynamically. I don't like the idea of going through 100+ pages and making the changes every time a load new images. Is it possible to...
2
1659
by: jimbo_vr5 | last post by:
Hey I think i've figured out the idea behind apply-templates. But going through the tutorial on <http://www.w3schools.com/xsl/xsl_apply_templates.asp> theres simply just something that i dont get! In the following i've copy pasted the example from <http://www.w3schools.com/xsl/xsl_apply_templates.asp> into this post. I divide into sections and my real question will come after the code snippet:
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10637
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7660
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.