Click to See Complete Forum and Search --> : Searching HTML


chriz
08-09-2005, 08:52 AM
Is there anyway you can get HTML to search for the following in its own source?:

<div align='right'>
<a href='javascript:scroll(0,0);'><img src='http://www02.so-net.ne.jp/~moonwave/top.gif' alt='' /></a>
</div>

There is an extremely large amount of text in the actual source, so i was wondering if there was anyway javascript/html can "match" that div above and type in after the </a> another image and stuff?? thanks a lot!

p.s. I cannot add anything like ID="thisThing" to the <div> tag cos its some sort of php server thingy doo-daa
(People who have an invisionfree server will know what i mean)
neway, any help is appreciated!

scragar
08-09-2005, 09:40 AM
if it's in your body try something like:

var x = document.getElementsByTagName("BODY")[0];
var w = x.innerHTML.split(" <div align='right'>\n\
<a href='javascript:scroll(0,0);'><img src='http://www02.so-net.ne.jp/~moonwave/top.gif' alt='' /></a>\n\
</div>");
w[1] = "XXXXXXXXXXXXXXXXXXXXXXXX" + w[1];
x.innerHTML = w.join(" <div align='right'>\n\
<a href='javascript:scroll(0,0);'><img src='http://www02.so-net.ne.jp/~moonwave/top.gif' alt='' /></a>\n\
</div>");

chriz
08-10-2005, 05:48 AM
nah, dosn't work, ne other ideas? Thanks for trying

arto
08-10-2005, 07:56 AM
Perhaps this: function firstElement(e) {
var i;

for (i=0;i<e.childNodes.length;i++)
if (e.childNodes[i].nodeType==1)
return e.childNodes[i];

return null;
}

var divs,i,fe;

divs=document.getElementsByTagName('DIV');
for (i=0;i<divs.length;i++) {
fe=firstElement(divs[i]);
if (fe && fe.href=='javascript:scroll(0,0);') {
fe=firstElement(fe);
if (fe && (fe.src=='http://www02.so-net.ne.jp/~moonwave/top.gif' || fe.src=='http://www02.so-net.ne.jp/%7Emoonwave/top.gif') ) {
divs[i].innerHTML+="<br>new content";
return;
}
}
}Arto