ie8 , ie9 ,ie10 호환성보기설정체크해서 팝업띄우기
오늘하루 이창을 열지 않음
<script type="text/javascript">
$(document).ready(function(){
var ver = getInternetExplorerVersion();
var agent = navigator.userAgent.toLowerCase();
var canvas = document.createElement('canvas');
var bStyle = document.body.style;
var popUrl = "A.html";//팝업창에 출력될 페이지 URL
var popOption = "width=520px; , height=490px; , resizable=no, scrollbars=no, status=no , center=yes , top=20, left=20"; //팝업창 옵션(optoin)
var popUrl2 = "B.html"; //팝업창에 출력될 페이지 URL
var popOption2 = "width=620px, height=720px, resizable=no, scrollbars=yes, status=no, center=yes, top=20, left=560"; //팝업창 옵션(optoin)
if (ver > -1){
if(ver == 7 && !('getContext' in canvas)){ // 7 일 때 (ie8에서 호환성모드이면 7로 인식 됨)
if(notice_getCookie("Notice") != "done"){
window.open(popUrl,"",popOption);
window.open(popUrl2,"",popOption2);
}
}
if( !('getContext' in canvas) && agent.indexOf('msie 9') > -1 && agent.indexOf('trident') == 51 && !('msTransition' in bStyle) && !('transition' in bStyle )){ // 호환성모드 체크확인
if(notice_getCookie("Notice") != "done"){
window.open(popUrl2,"",popOption2);
}
}
if(agent.indexOf('trident') == 51 && !canvas.getContext('webgl') && agent.indexOf('msie 7') > -1 && agent.indexOf('trident') > -1 ){ // 호환성모드 체크확인
if(notice_getCookie("Notice") != "done"){
window.open(popUrl2,"",popOption2);
}
}
}
});
function getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat(RegExp.$1);
}
return rv;
}
function notice_getCookie(name){
var nameOfCookie = name+"=";
var x = 0;
while(x <= document.cookie.length){
var y =(x+nameOfCookie.length);
if(document.cookie.substring(x,y) == nameOfCookie){
if((endOfCookie = document.cookie.indexOf(";",y)) == -1){
endOfCookie = document.cookie.length;
}
return unescape(document.cookie.substring(y,endOfCookie));
}
x=document.cookie.indexOf(" ",x)+1;
if(x == 0){
break;
}
}
return "";
}
</script>
[ A.html ]
<meta charset="utf-8">
<head>
<script type="text/javascript">
function notice_setCookie(name,value,expiredays){
var todayDate = new Date();
todayDate.setDate(todayDate.getDate()+expiredays);
document.cookie = name + "=" + escape(value)+ "; path=/; expires=" + todayDate.toGMTString()+ ";"
}
function notice_closeWin(){
if(document.form1.Notice.checked){
notice_setCookie("Notice","done",1);//1=팝업하루동안제한
}
self.close();
}
function na_call(str){
eval(str);
}
</script>
<style>
html, body {overflow-x: hidden; overflow-y: auto;}
img {max-width: none; display: block;}
</style>
</head>
<body>
<form name ="form1">
<div>
<img src="c.png" usemap="#map1" alt="브라우저 업그레이드 권장 안내" />
<label><input type="checkbox" name="Notice" onChange="notice_closeWin();">오늘은 이 창을 다시 열지 않음</label>
</div>
<map name="map1">
<area shape="rect" coords="115,350,173,410" href="http://windows.microsoft.com/ko-kr/internet-explorer/download-ie" target="_blank" alt="익스플로러 최신버전 다운로드" />
<area shape="rect" coords="180,350,250,410" href="https://www.google.co.kr/chrome/" target="_blank" alt="구글 크롬 다운로드" />
<area shape="rect" coords="260,350,320,410" href="https://www.mozilla.org/ko/firefox/new/" target="_blank" alt="모질라 파이어폭스 다운로드" />
<area shape="rect" coords="330,350,390,410" href="http://www.opera.com/ko" target="_blank" alt="오페라 다운로드" />
</map>
</form>
</body>
[ B.html ]
<meta charset="utf-8">
<head>
<script type="text/javascript">
function notice_setCookie(name,value,expiredays){
var todayDate = new Date();
todayDate.setDate(todayDate.getDate()+expiredays);
document.cookie = name + "=" + escape(value)+ "; path=/; expires=" + todayDate.toGMTString()+ ";"
}
function notice_closeWin(){
if(document.form1.Notice.checked){
notice_setCookie("Notice","done",1);//1=팝업하루동안제한
}
self.close();
}
function na_call(str){
eval(str);
}
</script>
<style>
html, body {overflow-x: hidden; overflow-y: auto;}
img {max-width: none; display: block;}
</style>
</head>
<body>
<form name ="form1">
<div><img src="d.jpg" usemap="#map1" alt="브라우저 설정" />
<label><input type="checkbox" name="Notice" onChange="notice_closeWin();">오늘은 이 창을 다시 열지 않음</label>
</div>
</form>
</body>
'차근차근 > JAVA Script' 카테고리의 다른 글
JavaScript Where To (0) | 2016.02.15 |
---|---|
HTML 렌더링 순서에 따른 <script> 태그 사용 권장사항 (0) | 2016.02.01 |
이미 클릭하면 팝업창띄우고 닫기버튼 누르면 새 페이지띄우기 (0) | 2015.11.04 |
ie8 , ie9 , ie10 팝업 , 호환성보기 설정 체크 (0) | 2015.11.02 |
[JS]자바스크립트로 user agent를 통해 모바일 인식하기 (0) | 2015.10.27 |