www.webdeveloper.com
Results 1 to 4 of 4

Thread: class, className not working in opera 10

  1. #1
    Join Date
    Sep 2009
    Posts
    5

    Question class, className not working in opera 10

    hey guys,
    this is my first post so first of all hey everyone .
    iv been writing a js component and now its in production it must work in all browsers, im new to opera and am having some problems with my js.

    in opera class and className dosent seem to be working when you say something like el.innerHTML = "<div class='theclass'>"; or when i do document.createElement or getElementById etc then do el.className = "theclass". or el.class="theclass" it just dosent do anything

    do any of you know about writing js for opera maby a trick for this or why it mieght not be working or a good site, i cant beleve that its not working.. i found out doing it all with object ie createElement and el.style.bla = works but then the skinning wont work because its based on css files. iv been reading js like tinyMCE to find out how they handel this but it dosnt seem to be a problem there or at least i havent found that part

    i greatly appreciate any replies.
    thnx in advance

    vbms

  2. #2
    Join Date
    Jun 2009
    Location
    West Jordan, Utah
    Posts
    91
    I just did some testing with Dragonfly (Tools > Advanced > Developer Tools, once it is loaded go to Scripts (top tab on left) then Command Line (bottom tab on left)) in Opera 10, and here's what I got:
    Code:
    >>> var element = document.createElement("div");
    undefined
    >>> element
    [object HTMLDivElement]
    >>> element.className = "test";
    "test"
    >>> element.className
    "test"
    >>> element.class
    undefined
    >>>
    Those undefined's are probably where functions don't return a value, except for element.class -- in firefox (using the FireBug addon and the Console feature) I got similar output:
    Code:
    >>> var element = document.createElement("div");
    >>> element
    <div>
    >>> element.className = "test";
    "test"
    >>> element.className
    "test"
    >>> element.class
    I don't believe there is a .class method or property for objects in JavaScript (though I thought there was), otherwise it would have returned something. ElementObject.className is the CSS class for an element. I hope that answers your first question.

  3. #3
    Join Date
    Sep 2009
    Posts
    5

    thnx for the reply

    hey thnx for the reply,

    the problem is the styles defined by the class are not being applied to the element after its being inserted via innerhtml or createElement. i think this is a bug in opera, im looking for a way that it works for all browsers. strange others dont seem to be having this problem. i will post here when i solve this. in the mean time feel free to post any input maby it will give me a clue.

  4. #4
    Join Date
    Sep 2009
    Posts
    5

    resolved solved

    aha i found out it was not a problem in my js. it was that the stylesheets were not being found. there seems to be a problem in the jsf a4j:loadstyle tag when its being rendered in an ajax response that is inserted in the result of another ajax response. ok so opera isnt quite as buggy as i thought

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles