| var newDoc=document.open("text/html","replace"); //重新加载引入 | |
| window.onload=function(){ | |
| //进入判断页面 | |
| changeDivHeight(); | |
| } | |
| window.onresize=function(){ | |
| //监听页面宽度值 | |
| changeDivHeight(); | |
| } | |
| //执行判断命令 | |
| function changeDivHeight(){ | |
| //获取body的宽度 | |
| var h = document.body.clientWidth | |
| console.log(h); | |
| if(h < 800) | |
| { | |
| //移动端 | |
| document.getElementById('css').href='css/ydd.css' //移动端 | |
| panddh('yddaohang') | |
| newDoc.close(); | |
| } | |
| else | |
| { | |
| //PC端 | |
| document.getElementById('css').href='css/PCd.css' //PC端 | |
| panddh('pcdaohang') | |
| newDoc.close(); | |
| } | |
| } | |
| //判断移动端 还是pc端 显示导航 | |
| function panddh(id){ | |
| if(id=='pcdaohang') | |
| { | |
| document.getElementById('pcdaohang').style.display="block"; | |
| document.getElementById('yddaohang').style.display="none"; | |
| } | |
| else | |
| { | |
| document.getElementById('pcdaohang').style.display="none";; | |
| document.getElementById('yddaohang').style.display="block" | |
| } | |
| } | |