1创建脚本块
2隐藏脚本代码
3浏览器不支持的时候显示
4链接外部脚本文件
5注释脚本
6输出到浏览器
7定义变量
8字符串相加
9字符串搜索
10字符串替换
11格式化字串
12创建数组
13数组排序
14分割字符串
15弹出警告信息
16弹出确认框
17定义函数
18调用JS函数
19在页面加载完成后执行函数
20条件判断
21指定次数循环
22设定将来执行
23定时执行函数
24取消定时执行
25在页面卸载时候执行函数
1<scriptlanguage=”JavaScript”>
2 JavaScriptcodegoeshere
3</script>
2 JavaScriptcodegoeshere
3</script>
2隐藏脚本代码
1<scriptlanguage=”JavaScript”>
2<!--
3 document.write(“Hello”);
4//-->
5</script>
在不支持JavaScript的浏览器中将不执行相关代码2<!--
3 document.write(“Hello”);
4//-->
5</script>
3浏览器不支持的时候显示
1<noscript>
2 Hellotothenon-JavaScriptbrowser.
3</noscript>
2 Hellotothenon-JavaScriptbrowser.
3</noscript>
4链接外部脚本文件
1<scriptlanguage=”JavaScript”src="/”filename.js"”></script>
5注释脚本
1
2//Thisisacomment
3document.write(“Hello”);//Thisisacomment
4/*
5 Allofthis isacomment
7*/
2//Thisisacomment
3document.write(“Hello”);//Thisisacomment
4/*
5 Allofthis isacomment
7*/
6输出到浏览器
1document.write(“<strong>Hello</strong>”);
7定义变量
1varmyVariable=“somevalue”;
8字符串相加
1varmyString=“String1”+“String2”;
9字符串搜索
1<scriptlanguage=”JavaScript”>
2<!--
3varmyVariable=“Hellothere”;
4vartherePlace=myVariable.search(“there”);
5 document.write(therePlace);
6//-->
7</script>
2<!--
3varmyVariable=“Hellothere”;
4vartherePlace=myVariable.search(“there”);
5 document.write(therePlace);
6//-->
7</script>
10字符串替换
thisVar.replace(“Monday”,”Friday”);
11格式化字串
1<scriptlanguage=”JavaScript”>
2<!--
3varmyVariable=“Hellothere”;
4document.write(myVariable.big()+“<br>”);
5document.write(myVariable.blink()+“<br>”);
6document.write(myVariable.bold()+“<br>”);
7document.write(myVariable.fixed()+“<br>”);
8document.write(myVariable.fontcolor(“red”)+“<br>”);
9document.write(myVariable.fontsize(“18pt”)+“<br>”);
10document.write(myVariable.italics()+“<br>”);
11document.write(myVariable.small()+“<br>”);
12document.write(myVariable.strike()+“<br>”);
13document.write(myVariable.sub()+“<br>”);
14document.write(myVariable.sup()+“<br>”);
15document.write(myVariable.toLowerCase()+“<br>”);
16document.write(myVariable.toUpperCase()+“<br>”);
17
18varfirstString=“MyString”;
19varfinalString=firstString.bold().toLowerCase().fontcolor(“red”);
20//-->
21</script>
2<!--
3varmyVariable=“Hellothere”;
4document.write(myVariable.big()+“<br>”);
5document.write(myVariable.blink()+“<br>”);
6document.write(myVariable.bold()+“<br>”);
7document.write(myVariable.fixed()+“<br>”);
8document.write(myVariable.fontcolor(“red”)+“<br>”);
9document.write(myVariable.fontsize(“18pt”)+“<br>”);
10document.write(myVariable.italics()+“<br>”);
11document.write(myVariable.small()+“<br>”);
12document.write(myVariable.strike()+“<br>”);
13document.write(myVariable.sub()+“<br>”);
14document.write(myVariable.sup()+“<br>”);
15document.write(myVariable.toLowerCase()+“<br>”);
16document.write(myVariable.toUpperCase()+“<br>”);
17
18varfirstString=“MyString”;
19varfinalString=firstString.bold().toLowerCase().fontcolor(“red”);
20//-->
21</script>
12创建数组
1<scriptlanguage=”JavaScript”>
2<!--
3varmyArray=newArray(5);
4myArray[0]=“FirstEntry”;
5myArray[1]=“SecondEntry”;
6myArray[2]=“ThirdEntry”;
7myArray[3]=“FourthEntry”;
8myArray[4]=“FifthEntry”;
9varanotherArray=newArray(“FirstEntry”,”SecondEntry”,”ThirdEntry”,”FourthEntry”,”FifthEntry”);
10//-->
11</script>
2<!--
3varmyArray=newArray(5);
4myArray[0]=“FirstEntry”;
5myArray[1]=“SecondEntry”;
6myArray[2]=“ThirdEntry”;
7myArray[3]=“FourthEntry”;
8myArray[4]=“FifthEntry”;
9varanotherArray=newArray(“FirstEntry”,”SecondEntry”,”ThirdEntry”,”FourthEntry”,”FifthEntry”);
10//-->
11</script>
13数组排序
1<scriptlanguage=”JavaScript”>
2<!--
3varmyArray=newArray(5);
4myArray[0]=“z”;
5myArray[1]=“c”;
6myArray[2]=“d”;
7myArray[3]=“a”;
8myArray[4]=“q”;
9document.write(myArray.sort());
10//-->
11</script>
2<!--
3varmyArray=newArray(5);
4myArray[0]=“z”;
5myArray[1]=“c”;
6myArray[2]=“d”;
7myArray[3]=“a”;
8myArray[4]=“q”;
9document.write(myArray.sort());
10//-->
11</script>
14分割字符串
1<scriptlanguage=”JavaScript”>
2<!--
3varmyVariable=“a,b,c,d”;
4varstringArray=myVariable.split(“,”);
5document.write(stringArray[0]);
6document.write(stringArray[1]);
7document.write(stringArray[2]);
8document.write(stringArray[3]);
9//-->
10</script>
2<!--
3varmyVariable=“a,b,c,d”;
4varstringArray=myVariable.split(“,”);
5document.write(stringArray[0]);
6document.write(stringArray[1]);
7document.write(stringArray[2]);
8document.write(stringArray[3]);
9//-->
10</script>
15弹出警告信息
1<scriptlanguage=”JavaScript”>
2<!--
3 window.alert(“Hello”);
4//-->
5</script>
2<!--
3 window.alert(“Hello”);
4//-->
5</script>
16弹出确认框
1<scriptlanguage=”JavaScript”>
2<!--
3varresult=window.confirm(“ClickOKtocontinue”);
4//-->
5</script>
2<!--
3varresult=window.confirm(“ClickOKtocontinue”);
4//-->
5</script>
17定义函数
1<scriptlanguage=”JavaScript”>
2<!--
3functionmultiple(number1,number2){
4varresult=number1*number2;
5returnresult;
6}
7//-->
8</script>
2<!--
3functionmultiple(number1,number2){
4varresult=number1*number2;
5returnresult;
6}
7//-->
8</script>
18调用JS函数
1<ahref=”#”onClick=”functionName()”>Linktext</a>
2<ahref="/”javascript:functionName"()”>Linktext</a>
2<ahref="/”javascript:functionName"()”>Linktext</a>
19在页面加载完成后执行函数
1<bodyonLoad=”functionName();”>
2 Bodyofthepage
3</body>
2 Bodyofthepage
3</body>
20条件判断
1<script>
2<!--
3varuserChoice=window.confirm(“ChooseOKorCancel”);
4varresult=(userChoice==true)?“OK”:“Cancel”;
5document.write(result);
6//-->
7</script>
2<!--
3varuserChoice=window.confirm(“ChooseOKorCancel”);
4varresult=(userChoice==true)?“OK”:“Cancel”;
5document.write(result);
6//-->
7</script>
21指定次数循环
1<script>
2<!--
3varmyArray=newArray(3);
4myArray[0]=“Item0”;
5myArray[1]=“Item1”;
6myArray[2]=“Item2”;
7for(i=0;i<myArray.length;i++){
8document.write(myArray[i]+“<br>”);
9}
10//-->
11</script>
12
2<!--
3varmyArray=newArray(3);
4myArray[0]=“Item0”;
5myArray[1]=“Item1”;
6myArray[2]=“Item2”;
7for(i=0;i<myArray.length;i++){
8document.write(myArray[i]+“<br>”);
9}
10//-->
11</script>
12
22设定将来执行
1<script>
2<!--
3functionhello(){
4window.alert(“Hello”);
5}
6window.setTimeout(“hello()”,5000);
7//-->
8</script>
9
2<!--
3functionhello(){
4window.alert(“Hello”);
5}
6window.setTimeout(“hello()”,5000);
7//-->
8</script>
9
23定时执行函数
1<script>
2<!--
3functionhello(){
4 window.alert(“Hello”);
5 window.setTimeout(“hello()”,5000);
6}
7window.setTimeout(“hello()”,5000);
8//-->
9</script>
2<!--
3functionhello(){
4 window.alert(“Hello”);
5 window.setTimeout(“hello()”,5000);
6}
7window.setTimeout(“hello()”,5000);
8//-->
9</script>
24取消定时执行
1<script>
2<!--
3functionhello(){
4 window.alert(“Hello”);
5}
6varmyTimeout=window.setTimeout(“hello()”,5000);
7window.clearTimeout(myTimeout);
8//-->
9</script>
2<!--
3functionhello(){
4 window.alert(“Hello”);
5}
6varmyTimeout=window.setTimeout(“hello()”,5000);
7window.clearTimeout(myTimeout);
8//-->
9</script>
25在页面卸载时候执行函数
1<bodyonUnload=”functionName();”>
2 Bodyofthepage
3</body>
4
2 Bodyofthepage
3</body>
4
这里收藏了,呵呵!!
JavaScript[对象.属性]集锦
http://thcjp.cnblogs.com/archive/2006/06/23/434310.html
评论
发表评论
您还没有登录,请您登录后再发表评论
相关推荐
javascript多窗口多框架实例介绍了多窗口多框架之间的相互调用
网页设计javascript-窗口框架.ppt
lhgdialog DIV弹出窗口框架,基于JavaScript,它与Alert弹出窗口有着本质的区别,lhgdialog DIV弹出窗口是JS+CSS结合打造的产物,界面非常漂亮,无刷新弹出窗口。
每个框架也是一个独立的浏览器窗口,它具有窗口的所有性质,所谓对框架的引用也就是对window对象的引用。不同层次框架间的互相引用,只要知道自己所在的层次以及另一个框架所在的层次和名字,利用框架引用的window...
欢迎使用 JavaScript 后台管理框架 - AMF AMF-可应用于网站后台、系统管理等领域。 01) 兼容: 天衣无缝的兼容性能,可完美运行于IE5.5\6+*、Firefox x+、Chrome x+、Safari x+、Opera x+等浏览器。 02) 快速...
Javascript,iframe的使用,框架,弹出新的窗口,警告框 window.open Javascript,iframe的使用,框架,弹出新的窗口,警告框 window.open Javascript,iframe的使用,框架,弹出新的窗口,警告框 window.open ...
JavaScript范例宝典 javascript工作中实例参考的很有帮助哦,留给自己以后工作中备用;另外因为整个文件很大(超过了csdn的限制15M),本人不得已按功能拆分上传。上传耗了我快一个小时,希望大家支持
第二篇为JavaScript对象,主要包括对象、核心对象、数组、正则表达式、对象模型和事件驱动、窗口与框架、文档对象、表单对象等内容;第三篇为高级技术,主要包括BOM中的其他对象、文档对象模型以及Ajax技术等内容。 ...
• 富客户端技术, 可以和任意后端技术(包括但不限于php, .Net, Java, python)或静态的HTML页面. • 包含40多个图形界面控件, 例如标签(Tabs),窗口对话框...• 和其他Ajax框架,如jQuery, prototype, mootools充分兼容.
JavaScript和Java的区别 JavaScript程序运行环境 编写第一个JavaScript程序 • 二、 JavaScript基本数据结构 JavaScript代码的加入 基本数据类型 表达式和运算符 范例:跑马灯效果 • 三、 ...
第二篇专门介绍javascript中内置对象的应用,内容包括javascript对象基础、窗口和框架、屏幕和浏览器对象、文档对象、历史对象和地址对象、表单对象和表单元素和脚本化cookie等。第三篇讲解的是javascript的高级技术...
第二篇专门介绍Javascript中内置对象的应用,内容包括Javascript对象基础、窗口和框架、屏幕和浏览器对象、文档对象、历史对象和地址对象、表单对象和表单元素和脚本化cookie等。第三篇讲解的是Javascript的高级技术...
书中从javascript 语言基础开始,分别讨论了图像、框架、浏览器窗口、表单、正则表达式、用户事件和cookie,并在上一版的基础上新增了两章,讲述jquery 框架的基础知识。本书不仅介绍了基础知识和使用方法,也深入...
02) 快速: 基于JavaScript原生态开发,运行快速高效、系统全部主体文件50多KB能极快载入启动。 03) 稳定: 系统使用Frameset模式开发,轻松运行上百标签窗口毫无压力。 有效解决了使用AJAX单一Dom加载模式过多卡机...
弹出窗口框架是一个简洁、高效、美观、易用的多功能弹出窗口组件。代码简洁,程序运行效率高,窗口样式更改简便,支持所有主流浏览器:IE6+,Firefox2.0+,Chrome(谷歌浏览器),Opera9.5+,Safari3.0+等
3.4.1 字符串对象 3.4.2 日期对象 3.5 桢结构和框架窗口(Frame,IFrame) 3.5.1 了解链接的Target 属性 3.5.2 由JavaScript,在不同的桢( 窗口) 间访问对象 3.5.3 了解IFrame 4 正则表达式和...
Window对象可以处理框架和框架之间的关系,通过这种关系在一个框架中处理另一个框架中的文档。他也是所有对象的顶级对象,通过Window对象的子对象进行操作,可以实现更多的效果。 1、Window对象属性 每个对象都有...
框架是一种可以操作的特殊窗口,当一个浏览器窗口包含多个框架的时候,可以使用window.fames[]对每个隔开的窗口对象进行访问。window.fames[]是一个数组,包含了窗口中的每个框架。本文主要介绍框架的访问、嵌套框架...
◆ 窗口对象和框架窗口(FrameSet、IFrame); ◆ 正则表达式的模式(Pattern)匹配――验证用户输入; ◆ 可参考的JavaScript 代码:预载入图片实现导航按钮的动态变化效果; ◆ 可参考的JavaScript 代码:显示...