Autor Zpráva
d
Profil *
ahoj jak pomoci js funkce dostanu doctype stranky, na kt. je fce spoustena...


function getDTD(){
str = document.doctype;//bohuzel nefunguje.... tedy v IE6
}
Oswald
Profil
Tady je jeden hodně perverzní způsob, který mě napadl:


function getDTD() {
var r, re, match, doctype;
if (document.doctype) {
return document.doctype;
}
r = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
r.open('GET', location.href, false);
r.send(null);
re = /<!DOCTYPE\s+([^\s]+)\s+PUBLIC\s+(['"])(.+?)\2\s+(['"])(.+?)\4/
match = r.responseText.match(re);
return {
name: match[1],
publicId: match[3],
systemId: match[5]
}
}

alert(getDTD().publicId);


Nejspíš to jde i jednodušeji. Moc jsem to netestoval.
Toto téma je uzamčeno. Odpověď nelze zaslat.

0