--
alternative for outerHTML property which is supported by Mozilla firefox browser by
prasaddevivara
I am using the outerHTML property to modify the HTML of existing elements in a web page in Internet Explorer. But same outerHTML property is not working in firefox browser, Anybody can tell me an alternative for outerHTML property in firefox. I am using the following function to display an image and alternate text behind all images of a weg page in Internet Explorer. Anybody can give solution for same in firefox browser.
function showimage()
{
var z=0,
tag=new Array('img');
for(n=0;n<tag.length;n++)
{
t=document.getElementsByTagName(tag[n]);
arr_lst=new Array();
{
for(i=0;i<t.length;i++)
{
{
var l;
if ((t[i].attributes.alt.specified) && (t[i].alt!=0) && (t[i].alt!="") && (t[i].alt.toLowerCase()!=".gif") && (t[i].alt.toLowerCase()!=".jpg") && (t[i].alt.toLowerCase()!=".png") && (t[i].alt.toLowerCase()!="bytes") && (t[i].alt.toLowerCase()!="kb") && (t[i].alt.toLowerCase()!="click here") && (t[i].alt.toLowerCase()!="more"))
{
l='alt=\"'+t[i].alt+'\"';
h=t[i].outerHTML;
t[i].outerHTML='<INPUT TYPE="image" alt="Valid Alt Text" SRC=" "><span style=\"color:#91060A;font:x-small arial;background:#FFFFC0;\">'+' '+l+' </span> '+h;
t[i].style.padding='3px',t[i].style.border='1px solid #91060A';
}
else if ((t[i].attributes.alt.specified)&&(t[i].alt==0) && (t[i].alt==""))
{
l='<INPUT TYPE="image" alt="Empty alt text" SRC=" ">';
h=t[i].outerHTML;
t[i].outerHTML='<span style=\"color:#91060A;font:x-small arial;\">' +l + '</span>'+h;
t[i].style.padding='3px',t[i].style.border='1px solid #91060A';
}
else if ((t[i].attributes.alt.specified) && (t[i].alt!=0) && (t[i].alt!="") && (t[i].alt.toLowerCase()==".gif" || t[i].alt.toLowerCase()==".jpg" || t[i].alt.toLowerCase()==".png" || t[i].alt.toLowerCase()=="bytes" || t[i].alt.toLowerCase()=="kb" || t[i].alt.toLowerCase()=="click here" || t[i].alt.toLowerCase()=="more"))
{
l='alt=\"'+t[i].alt+'\"';
h=t[i].outerHTML;
t[i].outerHTML='<INPUT TYPE="image" alt="Warning: Make sure alt is descriptive" SRC=" "><span style=\"color:#91060A;font:x-small arial;background:#FFFFC0;\">'+' '+l+' </span> '+h;
t[i].style.padding='3px',t[i].style.border='1px solid #91060A';
}
else
{
l='<INPUT TYPE="image" alt="Error: missing alt text" SRC=" ">';
h=t[i].outerHTML;
t[i].outerHTML='<span style=\"color:#91060A;font:x-small arial;\">'+l+'</span>'+h;
t[i].style.padding='3px',t[i].style.border='1px solid #91060A';
}
}
if(h!='')
z=z+1;
}
}
}
if(z==0)
alert('No Images');
Posted on May 30, 2005, 10:34 AM Respond to this message Goto Forum Home Responses