우선 넷스케이프 6이상인 경우를 구분하려면 다음과 같은 방법을 사용하면 된다.
 ns6 = !document.all &&  
             document.getElementById;

document.all가 거짓(false)이고 document.getElementById만 참(True)인 경우 인터넷 익스플로러는 해당 코드를 사용하지 않으면서 넷스케이프가 6이상인 경우만 해당 코드를 사용할 수 있게 된다.

넷스케이프 6 이상이면서 오페라(Opera)는 사용하지 못하도록 하려면? 그 방법은 다음과 같다.

 ns6noopera = !document.all &&  
             !window.opera &&  
             document.getElementById;

아주 가끔이긴 하지만, 오페라 7과 오페라 6을 구분해야 하는 경우도 있다. 이는 오페라 7의 여러 가지 새로운 기능 때문인데 그 방법은 다음과 같다.
 opera7 = window.opera &&  
         document.createComment;

오페라 6 이하의 경우는 다음과 같다.
 oldopera = window.opera &&  
           !document.createComment;

또 다른 경우로, 맥킨토시용 IE 5와 다른 브라우저를 구분해야 하는 경우가 있다. 다음은 윈도 기반에서의 인터넷 익스플로러 5 이상에서는 돌아가지 않고 맥킨토시용 인터넷 익스플로러 5 이상에서만 코드가 돌아가도록 하기 위한 조건이다.

 macie5 = document.all &&  
         !document.mimeType;

만일 위 조건에서 인터넷 익스플로러 4는 사용할 수 없도록 하기 위한 조건을 추가하려면 다음과 같이 하면 된다.
 macie5notothers = document.all &&  
                  document.getElementById &&  
                  !document.mimeType &&
                  !windows.opera;

윈도 기반의 인터넷 익스플로러의 경우를 좀 더 살펴보자. 만일 인터넷 익스플로러 4 이상에선 사용되지만 오페라의 경우는 사용하고 싶지 않은 경우 다음과 같은 조건을 사용하면 된다.
 Ie4upnoopera =document.all &&  
              !window.opera;

만일 인터넷 익스플로러 5.0에서만 돌아가도록 하기 위한 조건을 만들려면 약간의 변칙이긴 하지만 다음과 같이 해줄 수 있다.
 ie5 = document.all &&  
      !document.fireEvent &&  
      !window.opera;

인터넷 익스플로러 5.5에서만 돌아가도록 하기 위한 조건을 만들려면 다음과 같이 하면 된다.
 ie55= document.all &&  
      document.fireEvent &&  
      !document.createComment;

인터넷 익스플로러 6에서만 돌아가도록 하기 위한 조건을 만들려면 다음과 같이 하면 된다.
 ie6 = document.all &&  
      document.fireEvent &&  
      document.createComment;


document.write("appName : " + navigator.appName + "
"); document.write("appVersion : " + navigator.appVersion + "
"); document.write("userAgent : " + navigator.userAgent + "
"); document.write("platform : " + navigator.platform + "
"); if(navigator.userAgent.indexOf("MSIE 8.0") > 0 ){ document.write("IE8") } else if(navigator.userAgent.indexOf("MSIE 7.0") > 0 ){ document.write("IE7") } else if(navigator.userAgent.indexOf("MSIE 6.0") > 0 ){ document.write("IE6") } else if(navigator.userAgent.indexOf("Firefox") > 0 ){ document.write("Firefox") } else if(navigator.userAgent.indexOf("Safari") > 0 ){ document.write("Safari") } else if(navigator.userAgent.indexOf("Chrome") > 0 ){ document.write("Chrome") }

strBrowser = navigator.appName;
if (strBrowser == 'Netscape') {
           selectedColor = 'rgb(233, 244, 255)';
           cc = '#' + cc;
}
else if (strBrowser == 'Microsoft Internet Explorer') {

}

출처: http://www.silverwolf.co.kr/8301

Posted by lI헐헐Il
,