Welcome to WebmasterWorld Guest from 184.108.40.206
Forum Moderators: not2easy
But, if I do document.getElementById('prevfont').style.font = "18px Arial"; it works in every browser but Opera.
However, document.getElementById('prevfont').style.color = "red"; works just fine.
Oh, and as a little side note - if I try to set only 'font-size' or 'font-family' Opera refuses to run the rest of the script. Attempting to set 'font' causes Opera to just ignore that single line.
I'm not sure if Opera will allow the dynamic style changes you are trying to accomplish. IE and NS/MOZ Gecko allow this as you have witnessed, but I am not sure regarding Opera. There is still not full support for DOM.
Opera states that Version 6 is DOM compliant, and yes it is - the browser does recognise most of the DOM, though you can only READ the document, you can't WRITE to it using the DOM at the moment, consequently, you cannot alter CSS through the DOM.
Here is what Opera's TECH Specs [ [opera.com...] ]say on the subject:
cannot set the SRC attribute of iframes
We are currently working on DOM, based on the DOM 2.0 standard. We have also used some of Microsoft's extensions to DOM, notably the method for accessing CSS properties through a style attribute of the HTML elements. Modifying the document structure is not yet possible (ie. you cannot add or remove HTML elements). There are no plans to support Netscape's dynamic layers. Presently, we support getting and setting the following CSS attributes for absolutely positioned HTML elements:
color, background (only for setting of colors)
We support the following methods in the document object:
We support the following methods in HTML Elements:
Aah .. thanks papabaer! That's exactly what I needed to know. I was a bit puzzled since I could change the color, but not any other style properties. Too bad the keyCode isn't working .. I can live without that though ..
However, maybe I can solve the style.font thing using innerHTML/innerText instead? I need a workaround for Opera .. so I guess I'll just have to put my brain to work ;)