Click to See Complete Forum and Search --> : Changing html on the fly


geuis
02-17-2003, 07:21 AM
I'm just wondering if it is possible to change html being loaded into a window/page before IE renders it.

I would like to add some buttons and additional javascript to the top of a certain page when it loads. Also, is there anyway to change html coding?

eg.
normal page has <body>
<BODY bgcolor="black">

but I want to change it on the fly to add an onload() command

<BODY bgcolor="black" onload="doScriptAbove()">

Thanks,
Geuis

khalidali63
02-17-2003, 07:30 AM
Yep...piece of cake.

Just look into DOM specs and you will find your answer.

here is the link

http://zvon.org/xxl/DOM2reference/Output/index.html

cheers

Khalid

geuis
02-17-2003, 08:49 AM
ummm... what exactly am I looking for/at on that site??

khalidali63
02-17-2003, 08:59 AM
:D
May be this.

give an id attribute to the body tag

<body id="parent">

in the script tags

window.onload=walkDom;

function walkDom(){
var body = document.getElementById("parent");
//now set the attribute you wanted
body.setAttribute("bgcolor","black");
}

Khalid