Home >Web Front-end >JS Tutorial >Two ways to write JS code for IE_javascript skills
Sometimes we need to write separate JS processing code for compatibility under certain IE. There are many ways to do it:
1. Determine whether it is IE by detecting navigation.userAgent, and then write the processing code for the IE branch:
2. By declaring the @cc_on statement, you can enable conditions in the comments of the script. Compilation function, so that non-IE browsers will recognize them as comments and ignore them (actually tested, this method will be applicable in IE6-9!):