您的位置: 首页 > 技术文档 > 网页制作 > 事半功倍之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 设计比赛 网页制作 web标准 用户体验 UE photoshop Dreamweaver Studio8 Flash 手绘 CG
站点最新 站点最新列表
悟道web标准:前端性能优化
纯中文域名".中国"今日提交申请
世界之窗3.0皮肤设计大赛结果公布
使用jQuery制作滑动动画效果的层
如何设计网页横幅
Plump 图标设计
Subrat Nayak图标设计
百度知道推出文档分享服务
CSS Sprites(CSS雪碧):要还是不要?
UIRSS三周年纪念日推出V2公测版
栏目最新 栏目最新列表
Firefox的Jetpack扩展案例分析
阿里妈妈UED谈CSS Sprites技术
Photoshop中设计绿色时尚Web网站
操作Dom节点实现间歇滚动新闻
浏览器15年历史回顾
如何创建Firefox的Jetpack扩展
全透视:CSS Z-index 属性
用PS 3D工具绘制甜麦圈包装袋
悟道Web标准:让W3C标准兼容终端
悟道WEB标准:统一思想,遵循标准
>> 分页 首页 前页 后页 尾页 页次: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
请您注意:
·不良评论请用报告管理员,以利管理员及时删除。
·尊重网上道德,遵守中华人民共和国的各项有关法律法规
·承担一切因您的行为而直接或间接导致的民事或刑事法律责任
·本站评论管理人员有权保留或删除其管辖评论中的任意内容
·您在本站发表的作品,本站有权在网站内转载或引用
·参与本评论即表明您已经阅读并接受上述条款
推荐文档 | 打印文档 | 评论文档 | 报告错误  
专业书推荐 更多内容
《Web标准设计》
闪魂-FlashCS4完美入门与案例精粹
Waver_h's华丽世界
Illustrator CS3质感绘画表现技法
《Flash短片轻松学》
《用户体验要素》
《JavaScript语言精粹》
作品集 更多内容

初用数位板 公寓类地产站 被飞页面二 我的学习 贝克洛门窗 贝克洛门窗 iPhone界面飞机稿 贝克洛门窗