View Full Version : dhtml in opera?

Maximus - DFX
Jul 30th, 2002, 05:27 AM
I've gotta opera 6 for testing and to me its a really bad browser. It may be fast but it does a really really bad job or imitating browsers. I can't seem to get clipping to work in the "IE5.0" engine or the Opera 6.0 engine or Mozilla 5.0. NS4.78 seems to "sorta" and Mozilla 3.0 seems to be ok as well. Seriously, if your gonna imitate a browser, do it properly. Can anymore give my some help on opera workarounds are a resource for opera dhtml scripting.

Jul 30th, 2002, 05:33 AM
The only person I've seen seriously take to attempting DHTML for Opera is a member here by the name of brothercake.

Personally, Opera has the second best-CSS support (Gecko is the best, followed by Opera, with IE in the last), but is incapable of modifying the document structure after the page loads, which instantly makes it worthless for many dynamic effects. Opera 7 I read shall fix that, and we will see...

Graeme Hackston
Jul 30th, 2002, 05:35 AM
From what I understand the next version is supposed to have better DOM support. This might help in the mean time.


Jul 30th, 2002, 01:01 PM
Firstly - forget about Opera's emulation modes, they're for users not developers. Basically, a lot of sites employ global sniffer scripts which check for a version of IE or netscape and redirect all others to one of thsoe stupid "please upgrade your browser" pages. That's what emulation is for - Opera, set to idenitfy as MSIE, will get through the sniffer and attempt to run the code - sometimes successfully - because of Opera's bizzarre and patchy support for some proprietary IE features like document.all - but mostly not, because of Opera's severely limited DOM parsing module.

I sympathise with Opera for doing this - without it, many, otherwise very simple sites, would not be accesible to Opera at all.

But this in itself creates another problem, because Opera is not MSIE, or Netscape, or anything else other than Opera. It is a logic unto itself and always needs to be treated separately.

Fortunately, Opera has a unique object you can use to identify it, which works at all emulation modes, namely:

if(typeof window.opera != "undefined" ) { ... opera code ... }

If you want (or need) to differentiate between Opera 5 and 6, a more generic sniffer script might be useful - such as http://www.brothercake.com/scripts/sniffer.shtml

So, the most important thing is always have your Opera set to "identify as Opera", and always use the w3c methods like document.getElementById - never use document.all in Opera - getElementById works at all emulation modes, where .all only works in MSIE mode. Using the w3c collections will allow you to develop code that's not affected by the emulation mode the user has set.

Then remember these important limitations:

1 - no dynamic element modification of any kind, not even image resizing

2 - no support for clip

3 - no support for <img onload

4 - no support for offset properties in Opera 5, but Opera 6 is okay with this

You can find more comprehensive specs at http://www.opera.com/docs/specs/js/

Like jkd said, Opera CSS support rocks. We can only hope that Opera 7 brings in some proper DHTML. In the meantime, most javascript and simple dhtml is possible in Opera, like this (http://www.brothercake.com/dropdown)

Maximus - DFX
Jul 30th, 2002, 04:14 PM
Thanks for the info. I'll give the sources a look.

I must admit that I have no idea what you mean by Opera having great CSS support. I've almost never run into any problems with IE CSS support. The only problem I've seen in IE with CSS is that the filter prop won't work unless you have a width prop stated. I guess if you guys care, you might be able to fill me in on a little explaination as to why Opera and NS7 have such great CSS support.

Graeme Hackston
Jul 30th, 2002, 04:21 PM
Opera supports more w3c CSS standards than IE. You just can't manipulate many of them after the page is loaded.

Maximus - DFX
Jul 30th, 2002, 04:32 PM
Hehehe... So it doesn't exactly mean that the CSS is better. It just means it kisses W3Cs *** better :P You can understand why NS would be so big on the support, they got nothing going for them right now except that they can say they "strictly" follow W3C standards...

Graeme Hackston
Jul 30th, 2002, 04:43 PM
Not really, CSS support is better. DOM support is worse.

You should try Mozilla 1.0 (I think 1.1 is out). I find it's faster than IE6 and has better features (like "Tabs" and the bookmark interface).

Jul 30th, 2002, 07:19 PM
Originally posted by Maximus - DFX
Hehehe... So it doesn't exactly mean that the CSS is better. It just means it kisses W3Cs *** better :P

No, it means they care about making the developer's life easier. IE is missing out on some of the most powerful properties in CSS2, as well as most of the useful selectors. Working around them bloats your markup, and on top of working around all of IE's other quirks, you get ugl(ier)y markup that what you would have had.

This is a different argument for a different topic though, and one that I talk about a lot on these forums.

Just remember, W3C is there to make your life easier. If you don't mind writing 3 different codes for each browser, then go ahead and ignore them. but if you like writing code once, and having it run across all browsers, I'd recommend taking a look at their organization.

Anyway, let's get back on topic. :)

Maximus - DFX
Jul 30th, 2002, 08:34 PM
Well as far as I've seen, it take much less work in IE to write a document than it does in netscape. Now NS6/7 seems to be just as small so thats good. I have come across any compatibility problems in CSS between them so I'm happy. Anyway, it seems I'll just have to wait for Opera 7 for proper DOM support.