Contents
see List작성일 2016. 10. 21.
<script>
function getCookie(name) {
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
if (cookies[i].indexOf("=") == -1) {
if (name == cookies[i])
return "";
} else {
var crumb = cookies[i].split("=");
if (name == crumb[0].trim())
return unescape(crumb[1].trim());
}
}
};
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+'">');
} else {
document
.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">');
}
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>
를
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">
과같은 viewport 를 작성한 메타태그를 지우고 대체한다.
그후에
<button onclick="desktopMode()">pc <-> 모바일 전환 </button>
를 구현하여 사용하면된다.
javascript
| No | 작성일 | Title |
|---|---|---|
| 2045 | 2025. 11. 30. | TypeScript 타입 시스템 완벽 가이드 |
| 2044 | 2025. 11. 30. | React 18 새 기능 - Concurrent Features |
| 1864 | 2022. 07. 27. | [vue3] vue3 setup 에서 자식 컴포넌트 메소드(함수) 호출하기 |
| 1848 | 2022. 06. 11. | [ vuejs ] router 데이터 전달방식 |
| 1847 | 2022. 06. 11. | [ vuejs ] this.$router.push 혹은 link-to 를 setup() 에서 구현 |
| 1846 | 2022. 06. 10. | [ vuejs3 , spring-boot ] 웹개발은 어떻게 구성해야 하는가 |
| 1825 | 2022. 05. 24. | [ vuejs ] 부모,자식 요소의 메소드 호출 |
| 1421 | 2018. 12. 06. | [ angualrjs ] ajax header 포함시켜 $http 사용하기 |
| 1381 | 2017. 11. 30. | 문자열을 숫자로 바꾸는 방법 parseInt 와 Number 비교 |
| 1220 | 2017. 03. 28. | [ AngularJs] bootstrap nav dropdown |