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
(& ......
JavaScript动态加载CSS的三种方法 收藏
如果你有很多关联的CSS文件要一起加载,或者想动态的加载不同的CSS文件,那么下面的方法你一定对你有帮助。
第一种:一般用在外部CSS文件中加载必须的文件
程序代码
@import url(style.css);
/*只能用在CSS文件中或者style标签中*/
第二种:简单的在页面中加载一 ......
为了选择一个合适的脚本语言学习,今天查了不少有关Perl,Python,Ruby,Javascript的东西,可是发现各大阵营的人都在吹捧自己喜欢的语言,不过最没有争议的应该是Javascript现阶段还不适合用来做独立开发,它的天下还是在web应用上。 我主要是想做数据挖掘算法的研究,应该会处理大量的文本。提到文本处理,相信大部分人 ......
String.prototype.Trim=function(){
returnthis.replace(/(^\s*)|(\s*$)/g,"");
}
String.prototype.LTrim=function(){
returnthis.replace(/(^\s*)/g,"");
}
String.prototype.RTrim=function(){
returnthis.replace(/(\s*$)/g,"");
} ......