473,385 Members | 1,356 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,385 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 9129
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:...
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.