<script>
function getCookie(name) {
var from_idx = document.cookie.indexOf(name+'=');
if (from_idx != -1) {
from_idx += name.length + 1
to_idx = document.cookie.indexOf(';', from_idx)
if (to_idx == -1) {
to_idx = document.cookie.length
}
return unescape(document.cookie.substring(from_idx, to_idx))
}
}
var desktopModeTF = getCookie("DesktopMode");
var Scale = getCookie("DesktopModeScale");
var defWidth = 1170;
if (desktopModeTF == "true") {
document.write('<meta name="viewport" content="width=' + defWidth + ', user-scalable=yes, initial-scale=' + Scale + '">');
$("#v-pc").css({"display":"none"});
} else {
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">');
$("#v-mo").css({"display":"none"});
}
function desktopMode() {
if(getCookie("DesktopMode") == "true"){
setModeCookie(false);
}else{
//alert("다시한번 클릭하시면 원래대로 돌아옵니다.");
setModeCookie(true);
window.scrollTo(0, 0);
}
location.reload();
}
function setModeCookie(switchOn){
var now = new Date();
var time = now.getTime();
time += 3600 * 1000;
now.setTime(time);
document.cookie ='DesktopMode='+switchOn +'; expires=' + now.toUTCString() ;
if(switchOn){
document.cookie = "DesktopModeScale=" + $('html').width() / defWidth + '; expires=' + now.toUTCString() ;;
}
}
</script>
참고 : https://bestit.kr/sprt/blog/sprtBlogPost.pem?blogSeq=1139
'WEB Programming > jQuery' 카테고리의 다른 글
지정된 영역 내용 프린트 (0) | 2020.03.17 |
---|---|
PC, 모바일 분기처리 (0) | 2020.02.20 |