栄篱
2016-03-02 09:28
<script> document.write(screen.availHeight); document.write(screen.availWidth); document.write(screen.heigth); docuement.write(screen.width); document.write(screen.colorDepth); document.write(screen.pixelDepth); </script>
主要是写js的时候判断需求,比如响应式,我想只在手机上执行,那么if(window.width()<768){ 小于这个px的才执行 } .还有就是我想让一个浮动广告居中那么 我就可以给判断window.height(),获取高度的一半。等等有很多,都需要自己实践
window.open('','');里写上“,”什么意思?不写不是一样的么。表示刚刚开始学习,有些地方不太清楚,希望能解释下,谢啦~
<html>
<head>
<script>
function openWin()
{
myWindow=window.open('','');
myWindow.document.write("<p>This is 'myWindow'");
myWindow.document.write("<br>ScreenLeft: " + myWindow.screenLeft);
myWindow.document.write("<br>ScreenTop: " + myWindow.screenTop + "</p>");
}
</script>
</head>
<body>
<input type="button" value="Open 'myWindow'" onclick="openWin()">
</body>
</html>
web前端
JavaScript进阶篇
469182 学习 · 22584 问题
相似问题