Topic: changing css classes (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=29695" title="Pages that link to Topic: changing css classes (Page 1 of 1)" rel="nofollow" >Topic: changing css classes <span class="small">(Page 1 of 1)</span>\

 
argo navis
Bipolar (III) Inmate

From:
Insane since: Jul 2007

posted posted 11-14-2007 17:26

Hullo.

I am developing in IE, no access to FF or Opera right now, and I am in a bit of a
"have to get that right - now" cause the assignment is over on Friday (and it's 6pm).

This works in IE, however, I think "className" was an IE attribute only, but cannot google
any decent referenc about the topic :

code:
<script type="text/javascript">
            // ** Pages <div>isions handler script
            var divs = null;
            var links = null;
            
            function init(){
                links = document.getElementById("menu").getElementsByTagName("a");
                var tempDivs = document.getElementsByTagName("div");
                for(i = 0; i<tempDivs.length; i++){
                    if(tempDivs[i].className == "serverBlock"){
                        alert(i);
                    }
                }
            }
            
            window.onload = init;
        </script>

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana
Insane since: Aug 2000

posted posted 11-14-2007 19:24

I'm pretty sure that className is a standard DOM element. It should work in any DOM complient browser.

If you could give us a link, we could check it out in other browsers

.



-- not necessarily stoned... just beautiful.

argo navis
Bipolar (III) Inmate

From:
Insane since: Jul 2007

posted posted 11-14-2007 23:45

Intranet, NDA on the page content, and I am still striving with the domain name for publishing stuff
Don't even mention free hosting, banner adds make me cringe.

It works a threat in IE, main browser in the company, and I can now test the snippet in my Ubuntu at home with fake content - seems alright too.
(just a bunch of links in a div with correct class names, and the same amount of divs to be displayed-block or displayed-none.. "hover" effect).

The aim of the question was : design for scalability, in case they switch to this or that OS/browser in the future.
A high probability of dom compliance is, therefore, enough for me, thanks a bunch.

If anybody is interested, the script itself is not under NDA, so I could post the final version. ...enough comps for today though.

liorean
Paranoid (IV) Inmate

From: Umeå, Sweden
Insane since: Sep 2004

posted posted 11-15-2007 14:40

className is part of the DOM, every browser more recent than nn4 supports it

--
var Liorean = {
abode: "http://codingforums.com/",
profile: "http://codingforums.com/member.php?u=5798"};

Blaise
Paranoid (IV) Inmate

From: London
Insane since: Jun 2003

posted posted 11-26-2007 18:17

This may sounds silly, but does changing your for loop to the following help any?

code:
for(i = 0; i<tempDivs.length; i++){
    var currentDiv = tempDivs[i];
    if(currentDiv.className == "serverBlock"){
        alert(i);
    }
}



Cheers,

jdauie
Bipolar (III) Inmate

From: Missoula, MT
Insane since: Jan 2003

posted posted 12-08-2007 10:13

As far as finding reference docs in the future, a good place to start is msdn, where the pages include a "Standards Information" section near the bottom.

e.g.
CLASS/className is in the W3C DOM Level 1
altLeft Property is an IE only feature

That's one way to find this stuff. There are many.

(Edited by jdauie on 12-08-2007 10:15)



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu