차근차근/JAVA Script

호환성체크 | 팝업 | 오늘 하루 이 창을 열지않기

예쁜꽃이피었으면 2015. 11. 10. 06:53

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>





호환성체크_팝업_오늘 하루 이 창을 열지않기.txt




반응형