查看响应式网页设计的完整网站

时间:2015-04-06 04:37:50

标签: php jquery

我使用代码更改元视口

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {    

    var answer = confirm('Would you like to switch to the mobile version of kk');
    if (!sessionStorage.alreadyClicked) {
        if (answer)
        {
          console.log('yes');     
        }
        else
        {
          console.log('cancel');
           viewport = document.querySelector("meta[name=viewport]");
           viewport.setAttribute('content', 'width=device-width, initial-scale=0, maximum-scale=1.0, user-scalable=0');   
           //window.location = window.location.origin;  
        }
    }
}

如何在页面重新加载后保留元视口不被更改?

1 个答案:

答案 0 :(得分:0)

在上传时调用此javascript函数

<body onload="getDevicezType();">