469,361 Members | 2,298 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,361 developers. It's quick & easy.

how to implement oncontextmenu="return false;" to pass the W3C parser ?

me
I have got all my pages to comply with the W3C validator, except this
one line as below.

I need to keep the line (or the functionalilty) but it would be nice
to implement it in a way that gives me a 100% pass with W3C.

Any ideas?

Thanks.
Line 45, column 33: there is no attribute "ONCONTEXTMENU"

<body class="body" oncontextmenu="return false;">

You have used the attribute named above in your document, but the
document type you are using does not support that attribute for this
element. This error is often caused by incorrect use of the "Strict"
document type with a document that uses frames (e.g. you must use the
"Transitional" document type to get the "target" attribute), or by
using vendor proprietary extensions such as "marginheight" (this is
usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in
the document type you are using, as an undefined element will have no
supported attributes; in this case, see the element-undefined error
message for further information.

How to fix: check the spelling and case of the element and attribute,
(Remember XHTML is all lower-case) and/or check that they are both
allowed in the chosen document type, and/or use CSS instead of this
attribute.
Jul 23 '05 #1
11 43617
In comp.infosystems.www.authoring.html me said:
I have got all my pages


i know

What is the accepted way to share a message across multiple newsgroups?
http://smjg.port5.com/faqs/usenet/xpost.html

--
t h e o f l i t t l e v o i c e s
Jul 23 '05 #2
rf
me wrote:
I have got all my pages to comply with the W3C validator, except this
one line as below.


Why do you want to cripple my browser so I can't use the context menu to,
for instance, bookmark your site?

You don't by any change think that this tomfoolery will prevent me from
stealing your precious HTML do you?

--
Cheers
Richard.
Jul 23 '05 #3
me wrote:
I have got all my pages to comply with the W3C validator, except this
one line as below.

I need to keep the line (or the functionalilty) but it would be nice
to implement it in a way that gives me a 100% pass with W3C. <body class="body" oncontextmenu="return false;">


Use Javascript's addEventListener function to attach the event to the
body element.

--
Mark.
http://tranchant.plus.com/
Jul 23 '05 #4
me wrote:
I have got all my pages to comply with the W3C validator, except this
one line as below.

I need to keep the line (or the functionalilty) but it would be nice
to implement it in a way that gives me a 100% pass with W3C.


....but disabling the context menu is stupid.

--
Mark.
http://tranchant.plus.com/
Jul 23 '05 #5
me <me@no.where.com> wrote:
I have got all my pages to comply with the W3C validator, except this
one line as below.

I need to keep the line (or the functionalilty) but it would be nice
to implement it in a way that gives me a 100% pass with W3C.

Any ideas?

Thanks.
Line 45, column 33: there is no attribute "ONCONTEXTMENU"

<body class="body" oncontextmenu="return false;">


This is a Microsoft IE extension. There is no mechanism in the
standards for intercepting the opening of a context menu. Therefore,
there is no way to do so that will pass the validator.

If you feel you must be able to disable your users' context menus,
then you're in trouble because you can only do that to IE users. Users
of other browsers will be able to access their context menus just
fine.

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 23 '05 #6

"Mark Tranchant" <ma**@tranchant.plus.com> wrote in message
news:41***********************@ptn-nntp-reader02.plus.net...
me wrote:
I have got all my pages to comply with the W3C validator, except this
one line as below.

I need to keep the line (or the functionalilty) but it would be nice
to implement it in a way that gives me a 100% pass with W3C.

<body class="body" oncontextmenu="return false;">


Use Javascript's addEventListener function to attach the event to the
body element.


Is that a Javascript function? IE doesn't have it. It does have
attachEvent--but the IE documentation indicates that *that* is non-standard.
Yeah, the OP will get by the validator--but outside of IE he still won't get
what he wants.

Jul 23 '05 #7
On Mon, 01 Nov 2004 12:08:43 +0000, me <me@no.where.com> wrote:
I have got all my pages to comply with the W3C validator, except this
one line as below.


Don't use a Strict DTD unless you understand every error report from a
validator.

If you do, and you don't, then try revalidating it with a Transitional
DTD.

If it still won't validate, then take out the non-standard HTML
extensions that you're using, despite the very clear and obvious error
report you've been given.

And _NEVER_ turn off the whole context menu. That kills image
reloading, printing, and a whole pile of useful things as well as
whatever it was you thought you were doing. If you're paranoid about
content theft, then you need to be better about it; more secure, and
less irritating.

--
Smert' spamionam
Jul 23 '05 #8
On Mon, 1 Nov 2004 09:59:17 -0500, Harlan Messinger
<h.*********@comcast.net> wrote:
"Mark Tranchant" <ma**@tranchant.plus.com> wrote in message
news:41***********************@ptn-nntp-reader02.plus.net...
[snip]
Use Javascript's addEventListener function to attach the event to the
body element.


Is that a Javascript function?


Yes and no. It's a method exposed to ECMAScript implementations, but it's
defined by the W3C in DOM 2 Events.
IE doesn't have it.
No, as IE doesn't implement the Events module.
It does have attachEvent
A rather annoying thing to use. In event listeners added through HTML, the
on<event> properties of the element, or addEventListener in conforming
browsers, the this operator refers to the current target of the event.

Though that's fine in IE, event listeners added through attachEvent do not
have a correctly set this operator. In fact, it refers the global object
(window).

[snip]
Yeah, the OP will get by the validator--but outside of IE he still won't
getwhat he wants.


document.oncontextmenu = function() {return false;};

Depending on your point of view, that will, or will not, still produce an
invalid document tree, but it will pass the validator. I don't condone it
in either case, by the way.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #9
On Mon, 01 Nov 2004 15:01:34 +0000, Andy Dingley <di*****@codesmiths.com>
wrote:
On Mon, 01 Nov 2004 12:08:43 +0000, me <me@no.where.com> wrote:
I have got all my pages to comply with the W3C validator, except this
one line as below.


Don't use a Strict DTD unless you understand every error report from a
validator.


How else can you learn every error report?
Jul 23 '05 #10

"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opsgslbzemx13kvk@atlantis...
On Mon, 1 Nov 2004 09:59:17 -0500, Harlan Messinger
<h.*********@comcast.net> wrote:
Yeah, the OP will get by the validator--but outside of IE he still won't
getwhat he wants.


document.oncontextmenu = function() {return false;};

Depending on your point of view, that will, or will not, still produce an
invalid document tree, but it will pass the validator. I don't condone it
in either case, by the way.


Just to make it clear to the OP--your statement will add a method to the
document object called "oncontextmenu", but in most browsers it will sit
there, inert, just as if you had written

document.iservenopurpose = function() { return false; };

Jul 23 '05 #11
On Mon, 1 Nov 2004 09:59:17 -0500, Harlan Messinger
<h.*********@comcast.net> declared in
comp.infosystems.www.authoring.html:
Yeah, the OP will get by the validator--but outside of IE he still won't get
what he wants.


Just as well really. And most non-IE browsers have the option to block
disabling of the context menu anyway.

--
Mark Parnell
http://www.clarkecomputers.com.au
Jul 23 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Arvid Andersson | last post: by
15 posts views Thread by Cruella DeVille | last post: by
40 posts views Thread by Mark P | last post: by
4 posts views Thread by Luc The Perverse | last post: by
3 posts views Thread by Mark Shroyer | last post: by
29 posts views Thread by Java script Dude | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.