Detect the IE version
There are many ways to import scripts according to browser version, but It's true some internet service restrict the way to detect the browser version.
Simple trick is here:
<!--F IE Old Version Compatible -->
<script>var ielt9 = 0;</script>
<!--[if lt IE 9]>
<link href="./images/ie.fix.css" rel="stylesheet" />
<script>ielt9 = 1</script>
<![endif]-->
Explain: ie.fix.css is not necessary. Upper code is the code in my blog's <head> tag. Look at the <!--[if lt IE 9]>. It's not end of the comment. Why? There is no '-->' in the '<!--[if lt IE 9]>'. So browser parser doesn't detect that this line is the end of the comment. Except IE 8 and IE 7. So, what happened? IE 7, IE 8 will parse the line between <!--[if lt IE 9]> and <![endif]-->. That's all. This is all behavior that we want. So tricky, right?
We set the variable 'ielt9' in the <script> tag. And change the value if client using the old version of IE(ielt9 is set to 1).
jQuery Import
<script>if (ielt9 == 1) window.jQuery || document.write('<script src="./images/jquery-1.11.0.min.js"><\/script>'); else if(ielt9 == 0) window.jQuery || document.write('<script src="./images/jquery-2.1.0.min.js"><\/script>');</script>
Of course you can use the CDN server. But for me, that is not the preferring behavior. I don't trust the CDN server because I often experienced the delay of the page because of the CDN server, and It happens especially in Korea.
Upper code is simple. If you have just made the variable named 'ielt9', just use it. According to the value of the ielt9, you can simply import the jQuery according to the IE browser version. By 'document.write' function, script can be imported dynamically.
'Creation > Programming' 카테고리의 다른 글
Google Appengine 시작하기 (0) | 2016.02.13 |
---|---|
[안드로이드] 토글 버튼으로 타이머 작동/중지 컨트롤하기 (4) | 2014.10.31 |
Socket Programming - BrowserClient.c (1) | 2014.07.13 |
Mesh-connected computer partial sum(부분합) (10) | 2014.04.27 |
간단한 명령에는 jQuery 종속에서 벗어나자 (7) | 2014.04.25 |
Bitonic Sort in Distributed Parallel Computer System (1) | 2014.03.21 |
쓸만한 웹 HTML 에디터, widgEditor (3) | 2014.01.18 |
[Converter] Hex, Base64를 Plain Text(텍스트)로 변환해주는 사이트 (1) | 2014.01.17 |
[Javascript] 창크기 변화를 감지해서 애드센스(Adsense) 광고 옮기기 (27) | 2014.01.12 |
[정규표현식이란?] 정규표현식을 공부해보고 테스트 할 수 있는 사이트 (0) | 2014.01.11 |