473,406 Members | 2,259 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,406 software developers and data experts.

DOCTYPE detector

I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.
I found this, which tells me I have a hill to climb with no equipment.
http://javascript.about.com/library/bliebug.htm

I was going to use the document.doctype property if I could, but apparently
that isn't available unless I use strict. (just tried it with Strict, still
doesn't do anything).

here's what I've got. anybody got ideas that work or some pointers? I
don't have any money for books right now, and I wouldn't know which of 100's
of JS books to pick from.

I am using IE6, but I want this to be cross-browser.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<script language="JavaScript" type="text/javascript">
//document.getElementsByTagName('!DOCTYPE') generates an "object", but what
type? element? if so, why won't element properties work?
document.write(document.doctype); //prints nothing
document.write(document.getElementsByTagName('html ').getAttribute("xmlns"));
//prints nothing
document.write(document.getElementsByTagName('!DOC TYPE').hasAttribute("-//W3C//DTD
XHTML 1.0 Transitional//EN")); //prints nothing
//if (document.getElementsByName('!DOCTYPE') != null ||
document.getElementsByName('html').getAttribute('x mlns') != null) {
// document.write(document.getElementsByName('html'). innerHTML);
//}
</script>

</body>
</html>

I'm really frustrated. I lack info.

Jim Michaels
Aug 5 '06 #1
24 9130
Jim Michaels wrote:
I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.
I found this, which tells me I have a hill to climb with no equipment.
http://javascript.about.com/library/bliebug.htm

I was going to use the document.doctype property if I could, but apparently
that isn't available unless I use strict. (just tried it with Strict, still
doesn't do anything).

here's what I've got. anybody got ideas that work or some pointers? I
don't have any money for books right now, and I wouldn't know which of 100's
of JS books to pick from.

I am using IE6, but I want this to be cross-browser.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<script language="JavaScript" type="text/javascript">
//document.getElementsByTagName('!DOCTYPE') generates an "object", but what
type? element? if so, why won't element properties work?
document.write(document.doctype); //prints nothing
document.write(document.getElementsByTagName('html ').getAttribute("xmlns"));
//prints nothing
document.write(document.getElementsByTagName('!DOC TYPE').hasAttribute("-//W3C//DTD
XHTML 1.0 Transitional//EN")); //prints nothing
//if (document.getElementsByName('!DOCTYPE') != null ||
document.getElementsByName('html').getAttribute('x mlns') != null) {
// document.write(document.getElementsByName('html'). innerHTML);
//}
</script>

</body>
</html>

I'm really frustrated. I lack info.
Why do you need to know it, first of all?
Jim Michaels
Aug 5 '06 #2
Jim Michaels wrote:
>I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.
Why do you need to know it, first of all?
because generated singleton elements are different, such as <bror <br />
depending on whether it's html or xhtml.
Aug 5 '06 #3
Jim Michaels wrote:
Jim Michaels wrote:
I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.
Why do you need to know it, first of all?

because generated singleton elements are different, such as <bror <br />
depending on whether it's html or xhtml.
What are you trying to do with them? Can you use the same javascript
calls to make, get or manipulate them, regardless of the format of the
text? I'm not very familiar with xhtml I'm just thinking if it's so
hard it might not be necessary.

Aug 5 '06 #4
Jim Michaels said the following on 8/5/2006 1:41 AM:
>Jim Michaels wrote:
>>I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.
>Why do you need to know it, first of all?

because generated singleton elements are different, such as <bror <br />
depending on whether it's html or xhtml.
With IE, it's irrelevant as IE doesn't support - in any form - XHTML so
feeding it <br /leads to tag soup parsing.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 5 '06 #5

"darwinist" <da*******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Jim Michaels wrote:
Jim Michaels wrote:
I can't get any "universal" code working that tries to detect whether
the
document it's in is xhtml or html.
Why do you need to know it, first of all?

because generated singleton elements are different, such as <bror <br
/>
depending on whether it's html or xhtml.
I forgot to mention that all the calls I made do not work (and should
theoretically work)
really what I am building is an xhtml document detector (true/false).
What are you trying to do with them? Can you use the same javascript
calls to make, get or manipulate them, regardless of the format of the
text? I'm not very familiar with xhtml I'm just thinking if it's so
hard it might not be necessary.
real simple. things like:
if (isXhtml) {document.write('<br />');} else {document.write('<br>');}

xhtml affects things like singleton elements/tags like <brwhich become <br
/and <input ...which becomes <input ... />
it also forces element and attribute names to be lower case.

....I tried what you suggested, but got nowhere. that's why I am looking for
outside help. Apparently MSIE exposes other properties and methods for
Document object, and other related objects like Element, my two toughies.
methods/properties that are not exposed if you specify a Strict !DOCTYPE and
are used by a number of slightly older browsers.
Aug 5 '06 #6
Hi mr Michaels.
Only for fun i wrote this code. I tried it under Mozilla Firefox,
Opera 9.0 and
Internet Explorer 6.0. If there is a doctype in the document the
function detectDoctype() will return
object with 3 properties - xhtml - XHTML ot HTML , version - numer of
version and importance - stict, transitional etc. If there is no
DOCTYPE it will return null.
Best Regards.
/******************************
Version info "object"
******************************/
function versionInfo()
{
this.xhtml="";
this.version="";
this.importance="";
}
function detectDoctype(){
var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;
var myversionInfo=new versionInfo();
/*********************************************
Just check for internet explorer.
**********************************************/
if(typeof document.namespaces != "undefined"){
if(document.all[0].nodeType==8)
re.exec(document.all[0].nodeValue);
else
return null;
}else{
if(document.doctype != null)
re.exec(document.doctype.publicId);
else
return null;
}
myversionInfo.xhtml=RegExp.$1;
myversionInfo.version=RegExp.$2;
myversionInfo.importance=RegExp.$3;
return myversionInfo;
}
var myversionInfo=detectDoctype();
if(myversionInfo != null){
alert(myversionInfo.xhtml);
alert(myversionInfo.version);
alert(myversionInfo.importance);
}
else{
alert("There is no DOCTYPE in the code!");
}

Jim Michaels написа:
I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.
I found this, which tells me I have a hill to climb with no equipment.
http://javascript.about.com/library/bliebug.htm

I was going to use the document.doctype property if I could, but apparently
that isn't available unless I use strict. (just tried it with Strict, still
doesn't do anything).

here's what I've got. anybody got ideas that work or some pointers? I
don't have any money for books right now, and I wouldn't know which of 100's
of JS books to pick from.

I am using IE6, but I want this to be cross-browser.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<script language="JavaScript" type="text/javascript">
//document.getElementsByTagName('!DOCTYPE') generates an "object", but what
type? element? if so, why won't element properties work?
document.write(document.doctype); //prints nothing
document.write(document.getElementsByTagName('html ').getAttribute("xmlns"));
//prints nothing
document.write(document.getElementsByTagName('!DOC TYPE').hasAttribute("-//W3C//DTD
XHTML 1.0 Transitional//EN")); //prints nothing
//if (document.getElementsByName('!DOCTYPE') != null ||
document.getElementsByName('html').getAttribute('x mlns') != null) {
// document.write(document.getElementsByName('html'). innerHTML);
//}
</script>

</body>
</html>

I'm really frustrated. I lack info.

Jim Michaels
Aug 5 '06 #7
"Jim Michaels" <NO***************@yahoo.comwrote in
news:bO******************************@comcast.com:
real simple. things like:
if (isXhtml) {document.write('<br />');} else
{document.write('<br>');}

xhtml affects things like singleton elements/tags like <brwhich
become <br /and <input ...which becomes <input ... />
it also forces element and attribute names to be lower case.
Why not just use DOM methods to create *elements*, rather than writing
*tags* and making the browser's HTML parser do the work of turning them
into elements? That way you don't need to know/care how the tags were
written.
Aug 5 '06 #8


Jim Michaels wrote:
"darwinist" <da*******@gmail.comwrote in message
>>What are you trying to do with them? Can you use the same javascript
calls to make, get or manipulate them, regardless of the format of the
text? I'm not very familiar with xhtml I'm just thinking if it's so
hard it might not be necessary.

real simple. things like:
if (isXhtml) {document.write('<br />');} else {document.write('<br>');}

xhtml affects things like singleton elements/tags like <brwhich become <br
/and <input ...which becomes <input ... />
it also forces element and attribute names to be lower case.
You are making your life more complicated than it is. If you serve your
documents as text/html then the browser uses its HTML tag soup parser
and not XML parser and you can do all document.write('<br>') as much as
you like. If you served your documents as application/xhtml+xml to have
them parsed by an XML parser then IE would not render them at all and
Mozilla or Opera would not support document.write at all.
Thus as long as you want to use document.write your are in an
environment where HTML rules rule and there is no need to discover any
DOCTYPE or parsing mode.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 5 '06 #9
I thing in this way the code is much better and short.
function detectDoctype(){
var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;
var res=false;
/*********************************************
Just check for internet explorer.
**********************************************/
if(typeof document.namespaces != "undefined")
res=document.all[0].nodeType==8 ?
re.test(document.all[0].nodeValue) : false;
else
res=document.doctype != null ?
re.test(document.doctype.publicId) : false;
if(res){
res=new Object();
res['xhtml']=RegExp.$1;
res['version']=RegExp.$2;
res['importance']=RegExp.$3;
return res;
}else{
return null;
}
}
var myversionInfo=detectDoctype();
if(myversionInfo != null){
alert(myversionInfo.xhtml);
alert(myversionInfo.version);
alert(myversionInfo.importance);
}
else{
alert("There is no DOCTYPE in the code!");
}
go******@gmail.com написа:
Hi mr Michaels.
Only for fun i wrote this code. I tried it under Mozilla Firefox,
Opera 9.0 and
Internet Explorer 6.0. If there is a doctype in the document the
function detectDoctype() will return
object with 3 properties - xhtml - XHTML ot HTML , version - numer of
version and importance - stict, transitional etc. If there is no
DOCTYPE it will return null.
Best Regards.
/******************************
Version info "object"
******************************/
function versionInfo()
{
this.xhtml="";
this.version="";
this.importance="";
}
function detectDoctype(){
var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;
var myversionInfo=new versionInfo();
/*********************************************
Just check for internet explorer.
**********************************************/
if(typeof document.namespaces != "undefined"){
if(document.all[0].nodeType==8)
re.exec(document.all[0].nodeValue);
else
return null;
}else{
if(document.doctype != null)
re.exec(document.doctype.publicId);
else
return null;
}
myversionInfo.xhtml=RegExp.$1;
myversionInfo.version=RegExp.$2;
myversionInfo.importance=RegExp.$3;
return myversionInfo;
}
var myversionInfo=detectDoctype();
if(myversionInfo != null){
alert(myversionInfo.xhtml);
alert(myversionInfo.version);
alert(myversionInfo.importance);
}
else{
alert("There is no DOCTYPE in the code!");
}

Jim Michaels написа:
I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.
I found this, which tells me I have a hill to climb with no equipment.
http://javascript.about.com/library/bliebug.htm

I was going to use the document.doctype property if I could, but apparently
that isn't available unless I use strict. (just tried it with Strict, still
doesn't do anything).

here's what I've got. anybody got ideas that work or some pointers? I
don't have any money for books right now, and I wouldn't know which of 100's
of JS books to pick from.

I am using IE6, but I want this to be cross-browser.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<script language="JavaScript" type="text/javascript">
//document.getElementsByTagName('!DOCTYPE') generates an "object", but what
type? element? if so, why won't element properties work?
document.write(document.doctype); //prints nothing
document.write(document.getElementsByTagName('html ').getAttribute("xmlns"));
//prints nothing
document.write(document.getElementsByTagName('!DOC TYPE').hasAttribute("-//W3C//DTD
XHTML 1.0 Transitional//EN")); //prints nothing
//if (document.getElementsByName('!DOCTYPE') != null ||
document.getElementsByName('html').getAttribute('x mlns') != null) {
// document.write(document.getElementsByName('html'). innerHTML);
//}
</script>

</body>
</html>

I'm really frustrated. I lack info.

Jim Michaels
Aug 5 '06 #10
go******@gmail.com said the following on 8/5/2006 2:50 PM:
I thing in this way the code is much better and short.
It still doesn't do anything useful as far as anything of relevance.
It's a good exercise but that's all.

If the document is served with the proper MIME type, then the server
knows what it is and can tell the document what it is.

If it isn't served with the proper MIME type, then its tag soup and the
DTD is still irrelevant.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 5 '06 #11
OK. May be you are right.
Randy Webb написа:
go******@gmail.com said the following on 8/5/2006 2:50 PM:
I thing in this way the code is much better and short.

It still doesn't do anything useful as far as anything of relevance.
It's a good exercise but that's all.

If the document is served with the proper MIME type, then the server
knows what it is and can tell the document what it is.

If it isn't served with the proper MIME type, then its tag soup and the
DTD is still irrelevant.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 5 '06 #12
Georgi Naumov said the following on 8/5/2006 5:33 PM:
OK. May be you are right.
No "maybe" to it.

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 5 '06 #13
In article <C4******************************@comcast.com>, Jim Michaels
<NO***************@yahoo.comwrites
>I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.
Your first problem is that most documents in the World Wide Web are
neither :-(

The simplest solution is

var i_am_xhtml = true; // Or false, as appropriate

John
--
John Harris
Aug 6 '06 #14

<go******@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
I think in this way the code is much better and short.
function detectDoctype(){
var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;
var res=false;
/*********************************************
Just check for internet explorer.
**********************************************/
if(typeof document.namespaces != "undefined")
res=document.all[0].nodeType==8 ?
re.test(document.all[0].nodeValue) : false;
else
res=document.doctype != null ?
re.test(document.doctype.publicId) : false;
if(res){
res=new Object();
res['xhtml']=RegExp.$1;
res['version']=RegExp.$2;
res['importance']=RegExp.$3;
return res;
}else{
return null;
}
}
var myversionInfo=detectDoctype();
if(myversionInfo != null){
alert(myversionInfo.xhtml);
alert(myversionInfo.version);
alert(myversionInfo.importance);
}
else{
alert("There is no DOCTYPE in the code!");
}
terse is not necessarily better. as long as the code is reasonably
readable.
this 2nd version has brace matching errors.
Aug 6 '06 #15
I was tested this version in Opera, Mozilla and Internet explorer and
it worked nice.
Where is the brace matching errors?
Jim Michaels написа:
<go******@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
I think in this way the code is much better and short.
function detectDoctype(){
var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;
var res=false;
/*********************************************
Just check for internet explorer.
**********************************************/
if(typeof document.namespaces != "undefined")
res=document.all[0].nodeType==8 ?
re.test(document.all[0].nodeValue) : false;
else
res=document.doctype != null ?
re.test(document.doctype.publicId) : false;
if(res){
res=new Object();
res['xhtml']=RegExp.$1;
res['version']=RegExp.$2;
res['importance']=RegExp.$3;
return res;
}else{
return null;
}
}
var myversionInfo=detectDoctype();
if(myversionInfo != null){
alert(myversionInfo.xhtml);
alert(myversionInfo.version);
alert(myversionInfo.importance);
}
else{
alert("There is no DOCTYPE in the code!");
}
terse is not necessarily better. as long as the code is reasonably
readable.
this 2nd version has brace matching errors.
Aug 6 '06 #16

"Georgi Naumov" <go******@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
I was tested this version in Opera, Mozilla and Internet explorer and
it worked nice.
Where is the brace matching errors?
Jim Michaels ??????:
<go******@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
I think in this way the code is much better and short.
function detectDoctype(){
var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;
var res=false;
/*********************************************
Just check for internet explorer.
**********************************************/
if(typeof document.namespaces != "undefined")
res=document.all[0].nodeType==8 ?
re.test(document.all[0].nodeValue) : false;
else
res=document.doctype != null ?
re.test(document.doctype.publicId) : false;
if(res){
res=new Object();
res['xhtml']=RegExp.$1;
res['version']=RegExp.$2;
res['importance']=RegExp.$3;
return res;
}else{
return null;
}
}

right here causes end of function.

var myversionInfo=detectDoctype();
if(myversionInfo != null){
alert(myversionInfo.xhtml);
alert(myversionInfo.version);
alert(myversionInfo.importance);
}
else{
alert("There is no DOCTYPE in the code!");
}
terse is not necessarily better. as long as the code is reasonably
readable.
this 2nd version has brace matching errors.

Aug 7 '06 #17

"John G Harris" <jo**@nospam.demon.co.ukwrote in message
news:Gg**************@jgharris.demon.co.uk...
In article <C4******************************@comcast.com>, Jim Michaels
<NO***************@yahoo.comwrites
>>I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.

Your first problem is that most documents in the World Wide Web are
neither :-(
well, not if you have bought dreamweaver 8 or macromedia studio 8. default
document type is xhtml. which is what I have.
>
The simplest solution is

var i_am_xhtml = true; // Or false, as appropriate

John
--
John Harris

Aug 7 '06 #18
Jim Michaels said the following on 8/6/2006 9:32 PM:
"John G Harris" <jo**@nospam.demon.co.ukwrote in message
news:Gg**************@jgharris.demon.co.uk...
>In article <C4******************************@comcast.com>, Jim Michaels
<NO***************@yahoo.comwrites
>>I can't get any "universal" code working that tries to detect whether the
document it's in is xhtml or html.
Your first problem is that most documents in the World Wide Web are
neither :-(

well, not if you have bought dreamweaver 8 or macromedia studio 8. default
document type is xhtml. which is what I have.
Too bad you paid that much money for a program that attempts to produce
documents that are not supported by about 85% of the browsers in use.

Besides, using an XHTML DTD doesn't make a document XHTML to the browser.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 7 '06 #19
That's funny I just show how the function can be used. Never mind.

Jim Michaels написа:
"Georgi Naumov" <go******@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
I was tested this version in Opera, Mozilla and Internet explorer and
it worked nice.
Where is the brace matching errors?
Jim Michaels ??????:
<go******@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
I think in this way the code is much better and short.
function detectDoctype(){
var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;
var res=false;
/*********************************************
Just check for internet explorer.
**********************************************/
if(typeof document.namespaces != "undefined")
res=document.all[0].nodeType==8 ?
re.test(document.all[0].nodeValue) : false;
else
res=document.doctype != null ?
re.test(document.doctype.publicId) : false;
if(res){
res=new Object();
res['xhtml']=RegExp.$1;
res['version']=RegExp.$2;
res['importance']=RegExp.$3;
return res;
}else{
return null;
}
}


right here causes end of function.

var myversionInfo=detectDoctype();
if(myversionInfo != null){
alert(myversionInfo.xhtml);
alert(myversionInfo.version);
alert(myversionInfo.importance);
}
else{
alert("There is no DOCTYPE in the code!");
}
terse is not necessarily better. as long as the code is reasonably
readable.
this 2nd version has brace matching errors.
Aug 7 '06 #20
>I was tested this version in Opera, Mozilla and Internet explorer and
>it worked nice.
Where is the brace matching errors?
Jim Michaels ??????:
after a mistaken post, no brace matching error. just me misreading the
code. usually functions are separated from each other and from other code
with at least 1 blank line as a rule (usually 3), and I thought the
following test code was part of the function.

however, I tested it with a document that had no doctype, and it reported
xhtml instead of HTML. How would you get it to report html? with no
doctype, documents default to HTML.
Aug 7 '06 #21
Please show me how you try to use function. If there is no doctype it
will return null.

Best Regards
Jim Michaels написа:
I was tested this version in Opera, Mozilla and Internet explorer and
it worked nice.
Where is the brace matching errors?
Jim Michaels ??????:

after a mistaken post, no brace matching error. just me misreading the
code. usually functions are separated from each other and from other code
with at least 1 blank line as a rule (usually 3), and I thought the
following test code was part of the function.

however, I tested it with a document that had no doctype, and it reported
xhtml instead of HTML. How would you get it to report html? with no
doctype, documents default to HTML.
Aug 7 '06 #22
In article <E7******************************@comcast.com>, Randy Webb
<Hi************@aol.comwrites

<snip>
>Besides, using an XHTML DTD doesn't make a document XHTML to the browser.
Especially if there's a meta tag saying content="text/html" :-(

John
--
John Harris
Aug 7 '06 #23
John G Harris said the following on 8/7/2006 2:36 PM:
In article <E7******************************@comcast.com>, Randy Webb
<Hi************@aol.comwrites

<snip>
>Besides, using an XHTML DTD doesn't make a document XHTML to the browser.

Especially if there's a meta tag saying content="text/html" :-(
By the time the DTD is processed it's too late. Never mind ever making
it to the meta tags.

Served with an XHTML mime-type (app/xhtml+xml, app/xml or
text/xml) IE won't render it at all - irregardless of any DTD or META
tags in the document.

Served with an HTML mime type then no browser will render it as XHTML.
No matter what DTD or META tags you put in the document.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 7 '06 #24
May be you call function incorrectly. This is the example how to call
the function and it will returned correct result. See here:
http://gonaumov.googlepages.com/withdoctype.html
and here: http://gonaumov.googlepages.com/withouddoctype.html .
Best Regards.

Jim Michaels написа:
I was tested this version in Opera, Mozilla and Internet explorer and
it worked nice.
Where is the brace matching errors?
Jim Michaels ??????:

after a mistaken post, no brace matching error. just me misreading the
code. usually functions are separated from each other and from other code
with at least 1 blank line as a rule (usually 3), and I thought the
following test code was part of the function.

however, I tested it with a document that had no doctype, and it reported
xhtml instead of HTML. How would you get it to report html? with no
doctype, documents default to HTML.
Aug 7 '06 #25

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

Similar topics

2
by: Joh | last post by:
Hello, (sorry long) i think i have missed something in the code below, i would like to design some kind of detector with python, but i feel totally in a no way now and need some advices to...
39
by: Holly | last post by:
I'm trying to validate my code and I can't figure out what kind of doctype I have. The validator can't tell me anything because it can't move beyond the doctype declaration. ...
43
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a...
4
by: Chinmoy Mukherjee | last post by:
Hi All, Do you know of any free memory leak detector for C++ for windows OS? Regards, Chinmoy
2
by: Leon Lambert | last post by:
I was wondering if someone could post some links to some bug pattern detector software for C#. I found this very interesting article about pattern detectors for Java so wanted to investiage one for...
1
by: Lighter | last post by:
Is there a way to write a memory leak detector supporting new(nothrow)? For example, #include <My_Debug_New.h> using namespace std; int main() {
0
by: Dmitriy V'jukov | last post by:
I want to announce release 1.1 of Relacy Race Detector. First of all, now you can freely DOWNLOAD latest version of Relacy Race Detector DIRECTLY FROM WEB:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.