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 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.
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.
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
Bookmarks