Spot the error

Tannin

Storage? I am Storage!
Joined
Jan 15, 2002
Messages
4,448
Location
Huon Valley, Tasmania
Website
www.redhill.net.au
What's wrong with this code?

It works fine in IE 5.0, IE 6., and Mozilla. In Opera 7.23 I get the text and it's functional but no stylesheet - just plain vanilla black and white text. In Opera 6.05, I just get a blank page.

OK, OK, mayube the correct question is "what's wrong with Opera", but I suspect that the real answer is that I have some bad code somewhere and that IE and Mozilla are coveringup my mistakes for me. Be nice to nail it.



<head>
<script>
<!--
var width1=1025
var width2=1281
if (screen.width<width1) {
document.write ('<link rel="stylesheet" type="text/css" href="t1024.css">\n');}
else if (screen.width<width2) { document.write ('<link rel="stylesheet" type="text/css" href="t1280.css">\n');}
else { document.write ('<link rel="stylesheet" type="text/css" href="t1600.css">\n');}
--!>
</script>
</head>
<body>

Assorted text and stuff goes here .....
 

Tannin

Storage? I am Storage!
Joined
Jan 15, 2002
Messages
4,448
Location
Huon Valley, Tasmania
Website
www.redhill.net.au
OK, I got it. Opera hates the HTML comment thingie <!--

Take out the comment markers (which are really rather pointless anyway, as I'm not bothering to try to make this readable in a non-CSS capabe browser anyway) and it works. Bizarre!

Is there some special magic to comments in Opera?
 

Buck

Storage? I am Storage!
Joined
Feb 22, 2002
Messages
4,514
Location
Blurry.
Website
www.hlmcompany.com
Oh yeah, and when you signal to open comments within the script tag, use:

Code:
//--

It is the double forward slashes that are important for comments in script tags, the stuff that follows on the same line can be anything.
 

Buck

Storage? I am Storage!
Joined
Feb 22, 2002
Messages
4,514
Location
Blurry.
Website
www.hlmcompany.com
By the way, if this same script will be used on several html pages, why not create a link to an external js file. That way all you need to include is:

Code:
<script src="xxx.js"></script>

When you make changes to that one js file, all of the pages will automatically be able to use it without requiring you to edit every page with this code.
 

Tannin

Storage? I am Storage!
Joined
Jan 15, 2002
Messages
4,448
Location
Huon Valley, Tasmania
Website
www.redhill.net.au
Cool! Thankyou Buck. I can't wait to get home and try it out.

Within a day or two, I'll upload a sample page from my mammoth trip report with pictures thingie, using that code, which I can then apply to the 50-odd pages of it when they are all finished. (Betterthan half done so far.)
 

timwhit

Hairy Aussie
Joined
Jan 23, 2002
Messages
5,278
Location
Chicago, IL
Tannin said:
Cool! Thankyou Buck. I can't wait to get home and try it out.

Within a day or two, I'll upload a sample page from my mammoth trip report with pictures thingie, using that code, which I can then apply to the 50-odd pages of it when they are all finished. (Betterthan half done so far.)

betterthan is not a word Tannin. You are going crazy with the combined words now, aren't you?
 

Tannin

Storage? I am Storage!
Joined
Jan 15, 2002
Messages
4,448
Location
Huon Valley, Tasmania
Website
www.redhill.net.au
Yeah. Sorry about that Tim. Ever since Tea'sbeengone there seemstohavebeen a certainlackoflunacy aroundtheplace. Bless her little hairy feet, if Tea was here, I'm sure she would say that lunacy is like lightning: it's always around and just takes the shortest path to earth. Seems that, as the most intelligent ape left standing, that is now me.

Damnit! I was perfectly happy beingthegrumpyone.
 

Fushigi

Storage Is My Life
Joined
Jan 23, 2002
Messages
2,890
Location
Illinois, USA
timwhit said:
Tannin said:
Cool! Thankyou Buck. I can't wait to get home and try it out.

Within a day or two, I'll upload a sample page from my mammoth trip report with pictures thingie, using that code, which I can then apply to the 50-odd pages of it when they are all finished. (Betterthan half done so far.)

betterthan is not a word Tannin. You are going crazy with the combined words now, aren't you?
Neither is Thankyou. :lol:
 

Tannin

Storage? I am Storage!
Joined
Jan 15, 2002
Messages
4,448
Location
Huon Valley, Tasmania
Website
www.redhill.net.au
Oh --- but wait! We are on Google now. Thanks to your contribution, there are now 12,700,001 hits!

PS to Buck: I like the include: much neater. A progress report and perhaps a sample in a couple of days.

Err ... dare I say "thank(?)you"?
 
Top