473,382 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 2038
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*********@gmx.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="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.javascript]
>"jojo" <jo*********@gmx.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="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.
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.javascript 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*********@gmx.dewrote in message
news:ea**********@registered.motzarella.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 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*********@gmx.dewrote in message
news:ea**********@registered.motzarella.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.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 24 '06 #10
"Randy Webb" <Hi************@aol.comwrote:
news:Q6******************************@comcast.com. ...

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" <jo*********@gmx.dewrote in message
news:ea**********@registered.motzarella.org...
>>Chris Tomlinson wrote:
[snip]
>>>< ... 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?
[snip]
>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.

FF 1.5.0.4 && Mozilla 1.7.13 even with
"Disable or replace context menus" NOT checked seem to allow the context
menu
to be 'bypassed'.

Perhaps its an issue with my local installation. If anyone would be so kind
at to try
the following and let me know the results.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>

<style type="text/css">
img{
width:165px;
height:300px;
border:0.1em dashed red;
margin:0.1em;
padding: 0.1em;
}
</style>

<script type="text/javascript">
function annoyance1(e)
{
var elm=e.target||e.srcElement;
if(elm.tagName.toLowerCase()=='img')
{
if(e.target)
{
e.preventDefault();
e.stopPropagation();
}
else if(e.srcElement)
{
e.returnValue=false;
}
alert('Copyright Notice Here.');
}
}
if(window.attachEvent)
{
document.attachEvent('oncontextmenu',annoyance1);
}
else if(window.addEventListener)
{
document.addEventListener('contextmenu',annoyance1 ,null);
}
</script>

<title>JavaScript Annoyance contextmenu</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
</head>

<body>
<img alt="Oven" src="http://files.photojerk.com/BootNic/oven.png">
<img alt="Oven" src="http://files.photojerk.com/BootNic/oven.png">
<img alt="Oven" src="http://files.photojerk.com/BootNic/oven.png">
<img alt="Oven" src="http://files.photojerk.com/BootNic/oven.png">
</body>
</html>
[snip]
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.

[snip]

--
BootNic Monday, July 24, 2006 8:18 PM

"I've noticed that the press tends to be quite accurate, except when
they're writing on a subject I know something about."
*Keith F. Lynch*
Jul 25 '06 #11

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

Similar topics

1
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...
4
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
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...
6
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
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...
8
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...
14
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.