06.28.06

finally usable Opera!

Posted in Opera, browsers, css, javascript, webdev at 07:22 pm

Of course, I don’t mean to sound like Opera-hater, but as I’ve been learning how to manipulate CSS via JavaScript recently, I was shocked to find out that even quite recent Opera 8.5x doesn’t provide way to access CSS with standard, W3C’s DOM way (or even dumb, not standard-compliant way that IE uses). But, fortunately, this was fixed in Opera 9. I don’t know if I’m a technocrat or something, but with browsers and W3C standards, I find myself wandering “how the heck we could live without this new feature?” too often.

And BTW, here’s the code I used to show something hidden by CSS.

function showSomething() {
                if (navigator.appName == "Microsoft Internet Explorer") {
                        //for dumbest browser ever, Internet Explorer
                        for (var x = 0; x < document.styleSheets[0].rules.length; x++) {
                                if (document.styleSheets[0].rules[x].selectorText==".classWeWantToShow") var n = x;
                        }
                        document.styleSheets[0].rules[n].style.display = "block";
                } else {
                        //proper, standard-compliant way to do it:
                        for (var x = 0; x < document.styleSheets[0].cssRules.length; x++) {
                                if (document.styleSheets[0].cssRules[x].selectorText==".classWeWantToShow") var n = x;
                        }
                        document.styleSheets[0].cssRules[n].style.display = "block";
                }
                document.getElementById(’somethingWeWantToHide’).style.display = "none";
        }

12.15.05

Why it isn’t quite OK to send XHTML as text/html

Posted in [X]HTML, browsers, css, web at 11:01 am

Wow. I’m just one tiny year late. And I would have saved myself at least a day-long headache if I’d read article explaining what you get and what you lose by serving XHTML as text/html MIME type.

You don’t want to read it? Here’s summary: XHTML sent as text/html instead of application/xhtml+xml is rendered in HTML mode (see previous post). When you write you code in XHTML and serve as text/html, it may appear perfectly valid, but after upgrading to proper application/xhtml+xml, it will probably be broken – e.g. if you’re using SGML comments to hide their CSS and JavaScript or uppercase element types etc. Also – this is the problem I’ve had – be sure to rename your CSS element body to html.