javascript 得到当前页面可视高度和宽度
function getHeight(){
var yScroll;
if (window.innerHeight && window.scrollMaxY) {
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
yScroll = document.body.offsetHeight;
}
var windowHeight;
if (self.innerHeight) { // all except Explorer
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
// Explorer 6 Strict Mode
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
return pageHeight;
}
function getWidth(){
var xScroll
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all b
相关文档:
<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html', 'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
file://写/成一行
-->
</SCRIPT>
参数解释:
<SCRIPT LANGUAGE="javascript"&g ......
今天头儿复查代码,结果发现有的页面并没有相应的DOM元素,导致调用fuction出错。采用JavaScript中arguments对象可以很轻松的解决这个问题,而不需要再去判断元素之类的。so Good!
JavaScript中arguments函数对象是该对象代表正在执行的函数和调用它的函数的参数。使用方法:
[function.]arguments[n ]
其中function是 ......
在Java中,基本类型之间的强制转换也不是这样的,比如,整数要转换成字符串,必须使用Integer.toString()静态方法或者String.valueOf()静态方法,把字符串转换为整数,必须使用Integer.valueOf()。
可见,不能把JavaScript中的类型转换看作为“强制类型转换”。
在JavaScript中,Double类型和Int类型都是看作为 ......
要实现这个功能关键是要理解块的display属性。一个块的display属性设为none,就相当于这个块不存在。所以将要显示的多个块的display属性设为none,再根据需要将要显示的块的display属性设为block就可以做出标签页效果了。
(1) 建标签题以及各标签题所对应的显示内容:
<span id="span1 ......
创建RegExp对象实例的两种方式
1.使用RegExp对象的显示构造函数,语法为:new RegExp("pattern")[,"flags"];
2.使用RegExp对象的隐示构造函数,语法为:/pattern/flags;
3.flags为以下标志字符的组合
(1).g作全局标志,如果没有,匹配第一个
(2). i 忽略大小写
(3).m 多行标志
正 ......