Rey,
the question is a bit blurry because just doing a:
document.write()
is enough to change the current page content and its document type,
also I believe that's not the expected answer.
So my answer would be: I don't think it is possible to change the
current page DOCTYPE without wiping it's content first.
However In cases were this is needed as a side process to the main
document one way I have found and use is to create/inject a new
secondary document in an IFRAME using the required <!DOCTYPE ...> for
the new content.
After that you may be able to import/export from those different
document types (fx: HTML and XHTML) using importNode() / adoptNode() /
cloneNode().
The technique is working for me were I have to overlay content that
needs to be in XHTML over a main document that could be of different
type.
Using IFRAMES also ensure a level of isolation to avoid inferring
style and possibly clashing with existing class/id names in the
underlying main document.
--
Diego
On Thu, May 12, 2011 at 12:42 AM, Rey Bango <[email protected]> wrote:
> Hey all,
>
> Got asked this question today and didn't have an answer. Is it
> possible to change the doctype of a page using JavaScript?
>
> Rey
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
>
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]