1

how can i write a conditional comment for scripts that should run for all browsers except IE 8 and below?

i saw Conditional comment for 'Except IE8' ?

but how do i adapt it to include scripts files not inline scripts?

Community
  • 1
  • 1
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805

1 Answers1

1

The trick explained there would work just as well for external scripts — set a "this browser is old" flag in a conditional-commented inline script, and have your external scripts check for that flag.

If you mean to conditionally include entire script files, your best bet would probably be a script that browser-sniffs and dynamically includes the appropriate files. Otherwise, you could use downlevel-revealed conditional comments (thanks, bobince!).

Community
  • 1
  • 1
Chuck
  • 234,037
  • 30
  • 302
  • 389
  • Downlevel-revealed conditional comments are fine using the [valid syntax](http://stackoverflow.com/questions/1636282/hiding-html-portion-from-several-browsers-conditional-comments/1636365#1636365). It's a shame MS continue to promote the needlessly-invalid version. – bobince Sep 27 '10 at 02:32
  • @bobince: Thanks for that. I *thought* there was a valid syntax along those lines, but a search on MSDN convinced me I was remembering wrong. That is a shame. – Chuck Sep 27 '10 at 02:36