scriptable style access in Opera

V

VK

Is my understanding correct that
due to the lack of CSS2 support Opera doesn't allow any access to
inline/linked style declarations?
Say in case:
<style type="text/css">
..foo {
color: blue;
}
</style>
....
<div class="foo"...

There is no way to get a reference to the "foo" rule or to
change/remove it?
 
T

Thomas 'PointedEars' Lahn

VK said:
Is my understanding correct that
due to the lack of CSS2 support Opera doesn't allow any access to
inline/linked style declarations?

No. Recent versions of Opera support CSS2 features that are not
discontinued in CSS2.1:

<URL:http://www.opera.com/docs/specs/css/>

However, recent versions of Opera do not support W3C DOM 2 Style --

<URL:http://www.opera.com/docs/specs/js/dom/css/>

--,
Say in case:
<style type="text/css">
.foo {
color: blue;
}
</style>
...
<div class="foo"...

There is no way to get a reference to the "foo" rule or to
change/remove it?

and that is why this is not possible.


PointedEars
 
M

Michael Winter

Is my understanding correct that due to the lack of CSS2 support
Opera

Opera has among the best CSS support of any browser in use on the Web.
doesn't allow any access to inline/linked style declarations?

It provides the ability to read and modify in-line style declarations,
no access to header (embedded) or external (linked) style sheets, and
read access to computed style properties.
Say in case:
<style type="text/css">
.foo {
color: blue;
}
</style>
...
<div class="foo"...

There is no way to get a reference to the "foo" rule or to
change/remove it?

Correct. That is a header (or embedded) style sheet rule.

Mike
 
M

Martin Honnen

VK wrote:

Say in case:
<style type="text/css">
.foo {
color: blue;
}
</style>
...
<div class="foo"...

There is no way to get a reference to the "foo" rule or to
change/remove it?

All you can do in Opera is to use the Core and HTML DOM to manipulate
HTML style elements e.g. to change something you could add a new style
element at the end of the head element e.g.

var styleElement = document.createElement('style');
styleElement.type = 'text/css';
styleElement.appendChild(document.createTextNode(
'.foo { background-color: transparent }'
));
document.getElementsByTagName('head')[0].appendChild(styleElement);

Or you can remove a complete style element e.g.
styleElement.parentNode.removeChild(styleElement)

Opera reacts to those DOM changes and makes the necessary CSS changes
resulting from that.
 
V

VK

Thanks to everyone, my worst assumptions are being confirmed. :-(

P.S. That was not a bias to Opera but indeed a practical question for
my project. But out of any bias it still sucks IMHO no matter how good
the static style support would be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top