您的位置: 首页 > 技术文档 > 网页制作 > 事半功倍之Javascript
在DW8中创建代码片段 回到列表 用菜单飞梭创建动态酷菜单
 事半功倍之Javascript

作者:刘昕 侯彧  时间: 2006-06-07 文档类型:翻译 来自:蓝色理想

第 1 页 事半功倍之Javascript [1]
第 2 页 事半功倍之Javascript [2]
第 3 页 事半功倍之Javascript [3]
第 4 页 事半功倍之Javascript [4]
第 5 页 事半功倍之Javascript [5]
第 6 页 事半功倍之Javascript [6]
第 7 页 事半功倍之Javascript [7]
第 8 页 事半功倍之Javascript [8]

6.使用重置按钮

<form name=form1>
<input type=reset name=reset1 value="rest form">
</form>
<script>
document.write("表单reset1的类型:"+document.form1.reset1.type+"<br>")
document.write("表单reset1的名称:"+document.form1.reset1.name+"<br>")
document.write("表单reset1的值:"+document.form1.reset1.value+"<br>")
</script>

7.使用提交按钮

<form name=form1>
<input type=submit name=submit1 value="submit form">
</form>
<script>
document.write("表单submit1的类型:"+document.form1.submit1.type+"<br>")
document.write("表单submit1的名称:"+document.form1.submit1.name+"<br>")
document.write("表单submit1的值:"+document.form1.submit1.value+"<br>")
</script>

8.使用复选按钮

<form name=form1>
<input type=checkbox name=cb1 >computer savvy?
</form>
<script>
document.write("表单cb1的类型:"+document.form1.cb1.type+"<br>")
document.write("表单cb1是否被选择?:"+document.form1.cb1.checked+"<br>")
document.write("表单cb1的名称:"+document.form1.cb1.name+"<br>")
</script>

9.使用单选按钮

<form name=form1>
<input type=radio name=radio1>male
<input type=radio name=radio1>female
</form>
<script>
document.write("第一个按钮被选择"+document.form1.radio1[0].checked+"<br>")
document.write("第二个按钮被选择"+document.form1.radio1[1].checked+"<br>")
document.write("按钮的名称"+ document.form1.radio1[0].name+"<br>")
document.write("按钮的个数"+document.form1.radio1.length)
</script>

10.使用选择列表

<form name=form1>
<select name=select1 size=4>
<option name=option1 value=lon>london,England</option>
<option name=option2 value=dub>Dublin,Ireland</option>
</select>
</form>
<script>
document.write("这个选择列表的名称"+document.form1.select1.name+"<br>")
document.write("这个选择列表的长度"+document.form1.select1.length+"<br>")
document.write("这个选择列表当前被选择的索引号"+document.form1.select1.selectedIndex+"<br>")
document.write("这个选择列表的尺寸"+document.form1.select1.size+"<br>")
</script>

11.验证表单的有效性

<script>
function validate(){
if(document.form1.text1.value!='1'||'2'||'3'||'4'){
alert("请输入1~4的整数")
}
}
</script>
<form name=form1>
请输入1~4的整数:
<input type=text name=text1 size=4 onchange=validate()>
</form>

12.控制表单焦点

<form name=form1>
<input type=text name=text1 value=where is you focus?><br>
<input type=text name=text2 value=is there?><br>
<input type=text name=text3 value=or maybe here?><br>
<input type=button name=button1 value="text box #1" onclick=document.form1.text1.focus()><br>
<input type=button name=button2 value="text box #2" onclick=document.form1.text2.focus()><br>
<input type=button name=button3 value="text box #3" onclick=document.form1.text3.focus()><br>
</form>

第十三章 使用分栏

第十四章 使用navigator

1.使用navigator对象

<script>
document.write("navigator对象的属性"+"<br>")
document.write("appcodename:"+navigator.appCodeName+"<br>")
document.write("appname::"+navigator.appName+"<br>")
document.write("appversion:"+navigator.appVersion+"<br>")
document.write("platform:"+navigator.platform+"<br>")
document.write("userAgent:"+navigator.userAgent+"<br>")
</script>
<script>
document.write("navigator对象的方法"+"<br>")
document.write("javaEnabled():"+navigator.javaEnabled())
</script>

2.检查用户的浏览器

<script>
if(navigator.appName.indexOf("Microsoft")!=-1){
document.write("用户浏览器是微软的IE浏览器"+"<br>")}
else if(navigator.appName.indexOf("Netscape")!=-1){
document.write("用户浏览器是netscape的netscape浏览器"+"<br>")}
if(navigator.appVersion.indexOf("4.0")!=-1){
document.write("you are using a version 4.0compatible browser")
}
else{
document.write("this browser is not 4.0 compliant")}
</script>

3.检测用户的操作系统

<script>
if (navigator.platform.indexOf("win32")!=-1){
document.write("you are using a computer running windows 95 or highter")}
else{
document.write("this computer is not running windows 95 or higher")}
</script>

4.使用location对象

<script>
document.write("location对象的属性"+"<br>")
document.write("hash"+location.hash+"<br>")
document.write("hostname"+location.hostname+"<br>")
document.write("host"+location.host+"<br>")
document.write("href"+location.href+"<br>")
document.write("port"+location.port+"<br>")
document.write("search"+location.search+"<br>")
</script>

重新加载网页
<form name=form1>
<input type=button name=button1 value=重新加载本页 onclick=location.reload>
</form>

5.使用cookie

<script>
finction makecookie(){
if(!document.cookie){
name=prompt("请输入你的姓名");
document.cookie="name="+name+";";}
}
</script>

<body onload=makecookie()>
<script>
function makecookie(){
if(!document.cookie){
name=prompt("请输入你的姓名")
document.cookie="name="+name+";";
namestart=document.cookie.indexOf("=");
nameend=document.cookieindexOf(";");
document.writeln("your name is:"+document.cookie.substring(namestart+1,nameend)+",br>")
}
}
</script>

出处:蓝色理想
责任编辑:moby

上一页 事半功倍之Javascript [7] 下一页

◎进入论坛网页制作网站综合版块参加讨论

相关文章 更多相关链接
[JS]图片倒影效果
flash8与javascript集成
JavaScript经典效果集锦
用javascript封装的导航菜单
jscript/javascript条件编译
热门搜索:CSS Fireworks 设计比赛 网页制作 Dreamweaver Studio8 Flash
站点最新 站点最新列表
疯狂的程序员 第五十回
疯狂的程序员 第四十九回
疯狂的程序员 第四十八回
疯狂的程序员 第四十七回
疯狂的程序员 第四十六回
疯狂的程序员 第四十五回
疯狂的程序员 第四十四回
疯狂的程序员 第四十三回
疯狂的程序员 第四十二回
疯狂的程序员 第四十一回
栏目最新 栏目最新列表
火星人的耳机
公司正式宣布创业失败
用corelDEAW 12打造唇膏
二行代码解决全部网页木马
一行代码解决iframe挂马
Photoshop制作星空爆炸效果
CorelDraw 12打造休闲裤
Firework如何画特殊的切角图形
Firework打造韩式风格的手提袋
flash实例:打造佛光效果
>> 分页 首页 前页 后页 尾页 页次:8/81个记录/页 转到 页 共8个记录

蓝色理想版权申明:除部分特别声明不要转载,或者授权我站独家播发的文章外,大家可以自由转载我站点的原创文章,但原作者和来自我站的链接必须保留(非我站原创的,按照原来自一节,自行链接)。文章版权归我站和作者共有。

转载要求:转载之图片、文件,链接请不要盗链到本站,且不准打上各自站点的水印,亦不能抹去我站点水印。

特别注意:本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有,文章若有侵犯作者版权,请与我们联系,我们将立即删除修改。

本文总共有 10 条评论,现在显示最新的 5 条。评分:- llllllllllllllllllll + 评分人数: 9 ,平均分: 5.00


phoenixauv Publish at 2006-11-27 14:02:39 评分5
众里寻他千百度,后面怎么说来着?
反正就是太好了
jinjuduo Publish at 2006-6-13 16:04:57 评分5
太好了不得了!!!
websterjt Publish at 2006-6-11 17:22:02 评分5
Good!
cimke Publish at 2006-6-11 2:22:39 评分5
很好,+5分
wolf2999 Publish at 2006-6-8 17:08:23 评分5
好人啊。谢谢了。

查看全部评论

您的评论
用户名:  口令:
说明:输入正确的用户名和密码才能参与评论。如果您不是本站会员,你可以注册 为本站会员。
注意:文章中的链接、内容等需要修改的错误,请用报告错误,以利文档及时修改。
不评分 1 2 3 4 5
注意:请不要在评论中含与内容无关的广告链接,违者封ID
请您注意:
·不良评论请用报告管理员,以利管理员及时删除。
·尊重网上道德,遵守中华人民共和国的各项有关法律法规
·承担一切因您的行为而直接或间接导致的民事或刑事法律责任
·本站评论管理人员有权保留或删除其管辖评论中的任意内容
·您在本站发表的作品,本站有权在网站内转载或引用
·参与本评论即表明您已经阅读并接受上述条款
推荐文档 | 打印文档 | 评论文档 | 报告错误  
专业书推荐 更多内容
大师之路--Photoshop 完全解析
《超越CSS》新书上市
Don't Make Me Think 第2版
HTML与CSS入门经典(第7版)
《FLASH MX2004网站开发精粹》
《CSS入门经典》
《设计师谈网页设计思维》
作品集 更多内容

矢量绘图-唱歌给你听 汉唐家品 zhaopindiy 成都普瑞法科技 铅笔稿 帝景翰园 点格城市 华硕07新品海报