PDA

View Full Version : Removing a stylesheet from within the <body>


ronniebrown
08-21-2006, 12:46 PM
Hi,

I'm working on a site that has some code that I cannot get access to. Within this code, there are two <LINK> stylesheets that overwrite all the (correct) styles given to the page in the <HEAD> tag.

I would like to remove these <LINK> tags from the page and have tried to do so with the following code:


function delItem() {

myElement = document.getElementsByTagName("link");

if(myElement.length) {
lastElement = myElement.item(myElement.length-1)
docBody = document.getElementsByTagName("body").item(0)
removed = docBody.removeChild(lastElement)
}

}

This code works if I change the getElementsByTagName to "p", "div" or something similar, but not on the <LINK> tag.

The offending items are sitting inside a uniquely named div but, unfortunately, have no ID or class of their own.

Is there another way of doing this?

Thanks

r

felgall
08-21-2006, 09:50 PM
Change the rel attribute rather than tring to hide a tag that is not shown in the page in the first place. You need to change it from rel="stylesheet" to rel="alternate stylesheet"

Kravvitz
08-22-2006, 12:29 AM
I'd use the disabled property instead of changing the rel property of the <link>.