If doctype is <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
// do something
else
// do something
How to?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Right, I’m back after testing this in IE, Chrome, Firefox and Opera. IE will give you the full doctype with the following piece of code:
Unfortunately, this is probably incorrect, as Chrome, Firefox and Opera return
nullfornodeValue. Since none of them supportouterHTML, I can’t think of a way to get the full doctype, but you can get individual parts:However, that doesn’t work in IE, but it wouldn’t be too difficult to parse those out. You can use an
ifstatement to check thatnodeValueis notnulland fall back to checkingsystemIdorpublicId.Script used to run the tests: http://jsfiddle.net/Cwb8q/