javaScript获取页面,屏幕等高度与宽度
//获取页面数据
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else{ // Explorer Macwould also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
 
相关文档:
这两天的工作中遇到一个有关js的问题,很郁闷遇到js问题,因为没有报错,你根本就不知道自己错在哪里。
其实就是关于“document.getElementById("ss").innerText”的问题,我上网查关于js浏览器的兼容问题,可是都给出的解释是:
“HTML对象获取问题
FireFox
:document
.getElementById
(& ......
访问控件的主要对象是:document对象。分别对应当前文档所有的(子对象)个人观点。并且已经提供的几个主要方法来访问对象。
1. document.getElementById
2. document.getElementsByName
3 &n ......
1) 为什么加载javascript文件很重要?
javascript文件是比较特殊的,因为浏览器加载javascript是串行的。以为着在加载Javascript文件的时候,其他一切资源的下载包括页面的显示都会被阻塞。
2) 如何正确的加载JavaScript?
a. 将JavaScript文件放在页面的最后
因为JavaScript的加载会阻塞页面的显示,所以将JavaScrip ......
为了选择一个合适的脚本语言学习,今天查了不少有关Perl,Python,Ruby,Javascript的东西,可是发现各大阵营的人都在吹捧自己喜欢的语言,不过最没有争议的应该是Javascript现阶段还不适合用来做独立开发,它的天下还是在web应用上。 我主要是想做数据挖掘算法的研究,应该会处理大量的文本。提到文本处理,相信大部分人 ......
function checkImgAddr(url){
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("post",url,false);
xmlhttp.send();
if(xmlhttp.readyState==4){
if(xmlhttp.status==404){
return "File Not Exist.";
}else if(xmlhttp.status == 200){
re ......