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

Dynamically Changing the DOCTYPE

I doubt this is possible, but I want to ask, just in case it is.

I have a project going using Google Maps. This project spits out an
HTML page template for people to post to their website and display a
map. Most of the people doing this will have limited knowledge of HTML.

I want to ensure that this page remains an XHTML 1.0 Transitional (or
Strict) page, in case some newbie removes the DOCTYPE or some slightly
more knowledgeable tries to change it to HTML 4.01 (which won't work
with the app).

I'm trying my best to make the app idiot-proof, even though all that
will do is cause the universe to create a bigger idiot.

Is it possible?

Jason

Oct 17 '05 #1
2 14767
"DartmanX" <fe***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I doubt this is possible, but I want to ask, just in case it is.

I have a project going using Google Maps. This project spits out an
HTML page template for people to post to their website and display a
map. Most of the people doing this will have limited knowledge of HTML.

I want to ensure that this page remains an XHTML 1.0 Transitional (or
Strict) page, in case some newbie removes the DOCTYPE or some slightly
more knowledgeable tries to change it to HTML 4.01 (which won't work
with the app).

I'm trying my best to make the app idiot-proof, even though all that
will do is cause the universe to create a bigger idiot.

Is it possible?

Jason


Could you just provide them a link to a page on your site?
Oct 17 '05 #2

DartmanX wrote:
I want to ensure that this page remains an XHTML 1.0 Transitional (or
Strict) page, in case some newbie removes the DOCTYPE or some slightly
more knowledgeable tries to change it to HTML 4.01 (which won't work
with the app).


So what do you want to do, simply parsing the string with the page
template for a DOCTYPE declaration to make sure the DOCTYPE declaration
is the one for XHTML 1.0 Transitional?
Or do you expect to be able to validate a string with markup against a
certain DTD?
Or is that page template loaded in a browser window and you want to use
the DOM to check whether there is a DOCTYPE declaration? For that you
can check e.g.

if (document.doctype) {
alert(document.doctype.name + '\r\n' + document.doctype.publicId +
'\r\n' + document.doctype.systemId)
}

where name would be
html
publicId
-//W3C//DTD XHTML 1.0 Transitional//EN
and systemId
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
for XHTML 1.0 Transitional.

But there is no requirement for document.doctype to be implemented in
HTML DOM implementations I think and IE/Win does not implement that
property. Mozilla however does, so does Opera 8. Not sure about support
in other browsers or older versions.

As for changing that with DOM methods, the W3C DOM Level 2 Core says:
"docType cannot be altered in any way, including through the use of
methods inherited from the Node interface, such as insertNode or
removeNode."

Mozilla 1.7 does not complain about doing

var newDoctype = document.implementation.createDocumentType(
'html',
'-//W3C//DTD XHTML 1.0 Transitional//EN',
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'
);

if (document.doctype) {
document.doctype.parentNode.replaceChild(newDoctyp e, document.doctype);
}

but I don't think that change will achieve anything.

DOM Level 3 Core says something to that:
"This node can be set at document creation time and later changed
through the use of child nodes manipulation methods, such as
Node.insertBefore, or Node.replaceChild. Note, however, that while some
implementations may instantiate different types of Document objects
supporting additional features than the "Core", such as "HTML" [DOM
Level 2 HTML], based on the DocumentType specified at creation time,
changing it afterwards is very unlikely to result in a change of the
features supported."
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 17 '05 #3

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

Similar topics

2
by: Satish Kumar Chimakurthi | last post by:
Hi all, An external solver program is dynamically producing files with different names 0000001.dat, 0000002.dat, 0000003.dat etc.....at regular intervals. These files contain all numeric data....
3
by: Billy | last post by:
Hello, I'm having a problem dynamically changing the color of a table background. I'm not sure exactly how to word this, but I'll give an example. I have a function called greentored(propname)...
34
by: The Good Son | last post by:
I'm trying to get my head around a problem that has me baffled. The following element: #wrapper {border:1px solid #000;background:#fff;} Renders as expected when using this DTD: ...
1
by: Dennis Marks | last post by:
I have a page with 3 divisions overlaying each other. I dynamically change the visibility to switch between them. On the Mac version of IE 5.1 I am not able to activate the scroll bars after making...
5
by: Tascien | last post by:
I was able to build an asp page dynamically depending on the question that the user answered through the online wizard... I think i can dynamically also create '.vb' or '.aspx' dynamically...
6
by: reynard | last post by:
I have a page that uses this doctype <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> but when I change to this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
2
by: John | last post by:
Hi Everyone, I have a question about dynamically changing the length of a varchar(n) field, in case the value I'm trying to insert is too big and will give a "truncated" error, but before the...
1
by: hellohi | last post by:
Hello Everyone, I wanted to change the existing variable names dynamically.( like www.aol.com ) in this site images and some text is changing dynamically. like wise i need javascrip to write ...
3
by: senthilkumarb | last post by:
Dynamically changing browser settings Browser have various settings like - cookies, cache, etc... How to check a browser whether cookies is Enabled OR Disabled in the client machine using...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.