Computer Science Canada

[Tutorial] Removing DIV ads

Author:  rizzix [ Mon Jan 23, 2006 5:31 pm ]
Post subject:  [Tutorial] Removing DIV ads

Sometimes when you apply for a "free" web hosting service, most of these companies prepend really ugly and annoying DIV ads to your web page.

Here's a script that I've tested to work with both Firefox and IE6.

(Note: Check your web hosting providers' policies/agreements, before you decide to use this. Most of them do not permit you to remove those ads.)

Javascript:
var z = document.body.childNodes;
for (var i = 0;  i < z.length;  i++) {
    if (z[i].nodeName == "DIV") {
        z[i].style.visibility = "hidden";
        z[i].style.height = "0px";
        z[i].style.width = "0px";
        document.body.removeChild(z[i]);
    }
}
Just make sure all your webpages begin with that code

for example:
HTML:
<div>
    Hello World
</div>

<script language="javascript" type="text/javascript">
    var z = document.body.childNodes;
    for (var i = 0;  i < z.length;  i++) {
        if (z[i].nodeName == "DIV") {
            z[i].style.visibility = "hidden";
            z[i].style.height = "0px";
            z[i].style.width = "0px";
            document.body.removeChild(z[i]);
        }
    }
</script>


<div>
    Bye World
</div>
will display
HTML:
Bye World


: