472,110 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,110 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 9007
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Joh | last post: by
39 posts views Thread by Holly | last post: by
43 posts views Thread by Gremlin | last post: by
4 posts views Thread by Chinmoy Mukherjee | last post: by
2 posts views Thread by Leon Lambert | last post: by
reply views Thread by Dmitriy V'jukov | last post: by

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.