/    Sign up×
Community /Pin to ProfileBookmark

getElementsByTagName(‘!’) problem in Firefox

Hi Everybody,

I have a problem with getElementsByTagName(‘!’) in Firefox. I have used the below code to show DOCTYPE tags found in the web page. Which is working fine for IE but not working in Firefox. Please tell me what function i need to use to get the <!> tags with in the page. Why the following code not working in firefox ?

My Script is as Below :
========================================================

function showDocType(){
docTagArray=document.getElementsByTagName(“*”);
alert(“docTagArray.length———–>” +docTagArray.length);
if(docTagArray.length>0){
for(i=0;i<docTagArray.length;i++){
s=new String(docTagArray[i].text).toUpperCase();
if(s.indexOf(‘XML’)!=-1){
if(docTagArray.length>1){
alert(docTagArray[i+1].text);
break;
}
else{
alert(docTagArray[i].text);
break;
}
}//end if
if(s.indexOf(‘DOCTYPE’)!=-1){
alert(docTagArray[i].text);
break;
}//end if
}//end for-loop
}//end if
else{
alert(‘DOCTYPE is Not Available for this Page!’);
}//end else

}//end function
========================================================

Thanks in Advance,

Prasad

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Orc_ScorcherOct 04.2005 — Because anything starting with <! is not an element. Anything you might want to know about a document's doctype is available in Mozilla via document.doctype, e.g. document.doctype.name or document.doctype.publicId.
Copy linkTweet thisAlerts:
@prasaddevivaraauthorOct 04.2005 — Thank you Very Much

I also got a minor problem while attaching a string I used &quot; but it is appearing as a string but not " in firefox browser. Can you please tell me how to add quotes. I have written the follwoing string, please observe it.

My code string as below :
=======================================


var s= "<!DOCTYPE " + docTagArray.name + " PUBLIC " + "&quot;" + document.doctype.publicId + "&quot; n" + "&quot;" + document.doctype.systemId + "&quot; >"
=======================================



Thanks once again,

Prasad
Copy linkTweet thisAlerts:
@KorOct 04.2005 — use escape unicode notation

for &quot; (or ") the escape javascript notation is [b]'u0022'[/b]
×

Success!

Help @prasaddevivara spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...