isn't quite ashamed enough to present

jr conlin's ink stained banana

2006-11-14

:: I Hate IE (and Opera's Been Warned)

Ok, here's one to put on your "Oh Dear Lord That's Retarded" list:

The following code produces no errors but fails to run either.
<b>this displays</b>
<script type='text/javascript'>
/* detect a comment */
if (document.getElementById('field').value.match(/<!--/))
alert('You entered a Comment');
</script>
More stuff that displays

Ok, that's greatly simplified, but for IE and Opera the above produces no Javascript errors or warnings, it simply doesn't work. Using the various consoles only states that there's no code there and that you should only set breakpoints where there's code.

This works peachy keen in Firefox.

Several freshly plucked forehead impressions into a desk later you'll figure out that '<!–' is interpreted by IE and Opera before <script> is and that it will happily consider all the content of that script tag invalid with no warning or error. Isn't that nice?

The solution is to break the "comment" sequence which appears inside of a string in a script tag sequence so that the HTML parser doesn't get "confused".

e.g.
var comment = '< '+'!--';

i'll add that you also have to do the same inane handling if you have "<sc"+"ript>" as a string because that am smart!

*grumble*

  1. 2006-11-15 10:57:20
    I've never really understood why so many people were so enthusiastic about Opera. Mind you, I haven't looked at it in several years, but my impression c. 2001 was that it's a slightly more broken version of IE. With ads. Sign me right up. Of course, at the same time what is now Firefox was a slightly more broken Netscape Navigator, with ideology, so there you go.
  2. bobthegoat
    2006-11-15 11:07:55
    I liked Opera (c. 2002-4) for three reasons: 1. First existance of tabbed browsing (more or less). 2. It saved your previous browsing session; I would do a lot of research and leave 15 different tabs open only to have them load, with "Back" intact, the next time I opened it. 3. Mouse gestures. Now Firefox supports most of that (1 and 2) and I can live without mouse gestures. Also Firefox has much better standards compliance. So now I use that and since I don't do web dev anymore, my other browsers mostly collect dust.
  3. 2006-11-15 14:06:41
    Well, the latest version of Opera is free (and without ads) It also is (in theory) more standards compliant than Firefox is with regards to weird CSS stuff. Unfortunately, it's also getting crapped up with various automatic plugins, wigets and hoo-hahs that need to be shut off. Oh yeah, and by the way Bob, Firefox has mouse gestures as well.
Wanna join in?

Blogs of note
personal that's my blog
(The Official Blog of the Internet)
memoirs of hydrogen guy matthew shepherd (quebec) rhapsodic.org Henriette's Herbal Blog lynne ydw i slumbering lungfish
geek Y!Cool Thing jeremy z
(The Official Website of the Internet)
dave's picks ultramookie Josh Woodward derek balling simon willison
news ars technica search engine watch

Powered by WordPress
Hosted on Dreamhost.