ie conditional comments need explanation

后端 未结 2 720
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 17:27

The following code is for reliable cross-browser IE version detection


 so any code inside a "false" conditional is just commented out;  IE then has its own syntax inside of that. As such, non-IE browsers just see a commented string, and IE treats it as a statement to execute.

Because of this, only one body tag shows, and only that one gets used.


More explanation of




To IE, this says:

 (ie conditional comment)
 (empty comment) (--> putting this here to stop SO ruining syntax highlighting :D)

 (ie conditional comment)

If you don't understand why, read the paragraph starting "Conditional comments for IE work...".

This same block, to any other browser looks like this:

 (this is just one comment, containing the text "[if (gt IE 9)|!(IE)]>
 (again, just one comment, containing "

提交回复
热议问题