javascript判断变量是否定义
直接使用未定义的Javascript变量时,页面会报错并无法执行,比如
if (varName=="")
{
}
需要先判断变量是否定义,使用typeof函数可以判断,如下使用:
if (typeof(ipaddr)=='undefined')
{
window.alert('ipaddr未定义');
}
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="edit ......
Javascript刷新页面的几种方法:
程序代码
1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refres ......
以创建按钮为例
<html>
<head>
<script>
function add1()
{
var obtn=document.createElement("input");
obtn.setAttribute("type","button");
obtn.setAttribute("value","test1");
document.body.appendChild(obtn);//注意如果有f ......