Because it's shorter than false. Also, I've just realised that if 0 will work undefined will too, so it's not necessary to return anything, and edited accordingly.
Because it's shorter than false. Also, I've just realised that if 0 will work undefined will too, so it's not necessary to return anything, and edited accordingly.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
So does HTML.
The value undefined is usually a special case though for event listeners. Ignoring it, or treating it like boolean true, allows authors to write event listeners without having to always return a value. I haven't checked if this applies here.
Mike
Truly? The validator says otherwise: a bug?Originally Posted by mwinter
Hm, best return 0 then, I suppose.The value undefined is usually a special case though for event listeners. Ignoring it, or treating it like boolean true, allows authors to write event listeners without having to always return a value. I haven't checked if this applies here.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Does null have the same value as 0 or false?
- Mike
Yes. What you posted is technically equivalent to (line breaks added for clarity):
Of course, no browser will see it that way, but the validator does. If only the parse tree option was still available...HTML Code:<script type="text"> javascript>document.oncontextmenu=function(){}< </script> script>
Doubtful. Can you post the snippet of code you used?The validator says otherwise: a bug?
No. It's its own value and type. If you meant, "Does it type-convert to boolean false like 0 and false?", then yes.
Mike
The precise code was:Code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <script type=text/javascript>document.oncontextmenu=function(){return 0}</script> </head> <body><p></body> </html>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
I made an incorrect assumption: a NET-enabled start-tag doesn't need to be closed with a NET; any end-tag will do.
The "real" equivalence is:
As you can see, this is valid, but not "correct".HTML Code:<script type="text"> javascript>document.oncontextmenu=function(){} </script>
Mike
Sorry to spam this very interesting discussion (no sarcasm intentended), but why are we talking about ways to shorten a useless script?![]()
Academic curiosity?![]()
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks