What's Up With Conditional Comments for IE?

V

vunet

I am investigating positive and negative sides of using conditional
comments:

<!--[if IE 6]>
@import url(/ie6.css);
<![endif]-->

My goal is to learn if JavaScript may handle it better or worse when
parsing the page. For example, is it fine to write what's above as:

if(ie6==true){ document.write "<style type='text/css'>@import url(/
ie6.css);</style>"; }
//ignore syntax if errors are there, you get the idea

Please let me hear some thoughts and feedback. Thank you.
 
C

Chaddy2222

I am investigating positive and negative sides of using conditional
comments:

<!--[if IE 6]>
@import url(/ie6.css);
<![endif]-->

My goal is to learn if JavaScript may handle it better or worse when
parsing the page. For example, is it fine to write what's above as:

if(ie6==true){ document.write "<style type='text/css'>@import url(/
ie6.css);</style>"; }
//ignore syntax if errors are there, you get the idea

Please let me hear some thoughts and feedback. Thank you.
The correct way to do it is with conditional comments.
If you use that method all other browsers will just ignore them.
But if you use JS things can get a bit messy.
 
V

vunet

The correct way to do it is with conditional comments.
If you use that method all other browsers will just ignore them.
But if you use JS things can get a bit messy.

Can you provide more details about what you call "a bit messy"? I
really want to know what may happen.
 
H

Harlan Messinger

vunet said:
Can you provide more details about what you call "a bit messy"? I
really want to know what may happen.

*Would* you rather write large chunks of your HTML page with
document.write instead of just typing in the HTML directly? *Would* you
prefer to write your own functions to determine which browser is in use?
I'm not seeing what you think the advantage would be.
 
V

vunet

*Would* you rather write large chunks of your HTML page with
document.write instead of just typing in the HTML directly?

There might be cases when it is good to do so. Otherwise, it would
never be done on practice.

*Would* you
prefer to write your own functions to determine which browser is in use?

Possibly yes. Is it a lot if you know what you are doing?
I'm not seeing what you think the advantage would be.

I am looking for disadvantages more than advantages of including files
dynamically. Say, scriptaculous.js uses document.write to include all
user-requested files keeping non-requested ones aside.
 
H

Harlan Messinger

vunet said:
There might be cases when it is good to do so. Otherwise, it would
never be done on practice.

*Would* you

Possibly yes. Is it a lot if you know what you are doing?
It's hard for someone who doesn't understand what advantages you imagine
to exist to tell you why they wouldn't be advantages or why the
disadvantages would outweigh them.
I am looking for disadvantages more than advantages of including
files dynamically. Say, scriptaculous.js uses document.write to
include all user-requested files keeping non-requested ones aside.

You would normally do that on the server, not on the client.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top