473,378 Members | 1,380 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,378 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 14764
"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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.