摘要:
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT> <input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打开><input name=Button onClick=document.all.WebBrowser.ExecWB(2,1) type=button value=关闭所有><in 阅读全文
随笔分类 - Javascript
window对象使用
2011-08-23 11:25 by 鹏雕, 231 阅读, 收藏,
摘要:
window对象是JavaScript浏览器对象模型中的顶层对象,包含多个常用方法和属性:1 打开新窗口window.open(pageURL,name,parameters)其中:pageURL为子窗口路径name为子窗口句柄parameters为窗口参数(各参数用逗号分隔) 如:window.open("http://www.cnblogs.com/zhouhb/","open",'height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=n 阅读全文
读写元素属性
2011-08-21 16:10 by 鹏雕, 163 阅读, 收藏,
摘要:
读写属性1: <p><aid="antares"href="test1.htm"title="Marssion">Antares</a></p> varanchor=document.getElementById("antares");varanchorId=anchor.getAttribute("id");varanchorTitle=anchor.getAttribute("title");alert("The 阅读全文
改变元素的类型
2011-08-21 15:49 by 鹏雕, 321 阅读, 收藏,
摘要:
没有什么直接的、简单的方法来改变一个元素的类型。改变元素类型的主要手段——克隆例: <h1>Changing the type of an element</h1><pid="starLinks"><ahref="test1.htm">Sirius</a><ahref="test2.htm">Achanar</a></p> vardiv=document.createElement("div");varp=documen 阅读全文
Create elements
2011-08-21 14:35 by 鹏雕, 197 阅读, 收藏,
摘要:
create element1: varanchorText=document.createTextNode("monoceros");varnewAnchor=document.createElement("a");newAnchor.href="http://www.baidu.com";//给新建的超链接节点添加链接属性newAnchor.appendChild(anchorText);varparent=document.getElementById("starLinks");varnewChild=par 阅读全文
窗体之间的交互(window.opener)
2011-08-19 17:53 by 鹏雕, 292 阅读, 收藏,
摘要:
窗体之间的交互(window.opener):<htmlxmlns="http://www.w3.org/1999/xhtml"><head><title>无标题页</title><scriptlanguage="javascript"type="text/javascript">functionopenwindow() {window.open("OpenerWindow.htm","newwin","height=300, 阅读全文
location对象
2011-08-19 16:00 by 鹏雕, 201 阅读, 收藏,
摘要:
Location 对象host 设置或检索位置或 URL 的主机名和端口号hostname 设置或检索位置或 URL 的主机名部分href 设置或检索完整的 URL 字符串assign("url") 加载 URL 指定的新的 HTML 文档。reload() 重新加载当前页replace("url") 通过加载 URL 指定的文档来替换当前文档<head><title>无标题页</title><scriptlanguage="javascript"type="text/javascr 阅读全文
history 对象
2011-08-19 14:34 by 鹏雕, 187 阅读, 收藏,
摘要:
Back ( ) 方法相当于后退按钮forward ( ) 方法相当于前进按钮go (1)代表前进1页,等价于forward( )方法;go(-1) 代表后退1页,等价于back( )方法 阅读全文
javascript三种对话框
2011-08-19 13:56 by 鹏雕, 204 阅读, 收藏,
摘要:
<head><title>无标题页</title><scriptlanguage="javascript"type="text/javascript">//第一种alert("第一种对话框");//第二种if(confirm("Are you sure?")) {alert("你点的确定"); }else{alert("你点的取消"); }varwin=null;functionopenWindow() {win=open(&q 阅读全文
javascript实现继承
2011-08-11 14:40 by 鹏雕, 204 阅读, 收藏,
摘要:
实现继承示例一: <scriptlanguage="javascript"type="text/javascript">functionClassA(sColor) {this.color=sColor; }ClassA.prototype.sayColor=function() {alert(this.color); }functionClassB(sColor,sName) {ClassA.call(this,sColor);this.name=sName; }ClassB.prototype=newClassA();ClassB.pro 阅读全文
区别 apply,call
2011-08-10 17:53 by 鹏雕, 257 阅读, 收藏,
摘要:
区分apply,call就一句话, foo.call(this,arg1,arg2,arg3)==foo.apply(this,arguments)==this.foo(arg1,arg2,arg3) <scriptlanguage="javascript"type="text/javascript">functionAdd(x,y) {returnx+y; }varo=newObject();document.write(Add.call(o,1,2),"<br />");//类似于//o.m=Add;//o 阅读全文
实参和形参
2011-08-10 15:03 by 鹏雕, 228 阅读, 收藏,
摘要:
<scriptlanguage="javascript"type="text/javascript">functioncheck(args) {varactual=args.length;//实际传入参数的个数varexpected=args.callee.length;//形参个数Function.lengthvarisPass=false;try {if(actual!=expected) {thrownewError("参数个数不匹配"); }else{isPass=true; } }catch(exception) 阅读全文
函数参数的属性:callee
2011-08-10 13:52 by 鹏雕, 195 阅读, 收藏,
摘要:
该属性用来引用当前正在执行的函数用于匿名函数的递归调用<scriptlanguage="javascript"type="text/javascript">vartemp;vartest=function(x) {if(x<= 1) {return1; }returnx+arguments.callee(x- 1);//引用当前正在执行的函数 }document.write(test(7));</script> 阅读全文
函数直接量
2011-08-09 14:39 by 鹏雕, 229 阅读, 收藏,
摘要:
函数直接量其实就是匿名函数数,函数的字面量function<scriptlanguage="javascript"type="text/javascript">//函数直接量(作为表达式)创建匿名函数vartest1=function(x) {returnx*x; }document.write(test1(2),"<br />");//指定函数名,递归调用vartest2=functionfact(x)//fact并不是函数名,而是为了递归调用方便的一个代号 {if(x<=1) {return1; }e 阅读全文
push and pop
2011-08-08 17:41 by 鹏雕, 241 阅读, 收藏,
摘要:
说明push() 方法可向数组的末尾添加一个或多个元素,并返回新的长度。pop() 方法将删除 arrayObject 的最后一个元素,把数组长度减 1,并且返回它删除的元素的值。如果数组已经为空,则 pop() 不改变数组,并返回 undefined 值。 <scriptlanguage="javascript"type="text/javascript">//先进后出(FILO)vartemp=[];document.write("Push<br />");temp.push(1, 2, 3, 4);doc 阅读全文
splice用法
2011-08-08 17:26 by 鹏雕, 412 阅读, 收藏,
摘要:
例: <scriptlanguage="javascript"type="text/javascript">//IE浏览器无效,使用FireFoxvartest=[1,2,3,4,5,6,7,8];//删除元素varresult=test.splice(4);//没有指定第二个参数表示从起始位置删至结尾,删除了5,6,7,8,将删除的数组返回for(vari=0;i<result.length;i++) {document.write(result[i],"<br />");//output 5 6 7 阅读全文
javascript声明数组三种方式
2011-08-08 14:12 by 鹏雕, 1510 阅读, 收藏,
摘要:
声明数组三种方式第一种var数组名=newArray();例:varemp=newArray()第二种var数组名=newArray(5,4,3,2,1,”test”);第三种varmisc= [ 1.1,true,"a", ]; varb= [[1,{x:1,y:2}], [2, {x:3,y:4}]]; 阅读全文
Date
2011-08-07 14:50 by 鹏雕, 221 阅读, 收藏,
摘要:
<scriptlanguage="javascript"type="text/javascript">//第一种参数varsomeDate=newDate(2008,05,20,12,00,00);document.write(someDate,"<br />");//第二种参数someDate=newDate("july 20 2008 12:30:30");document.write(someDate,"<br />");//获取系统当前日期vartod 阅读全文
浙公网安备 33010602011771号