web技术概论第六周作业
2015-11-13 11:55
267 查看
Homework 0:
JavaScript Browser Sniffer is a browser identifier written in JavaScript (EcmaScript) and released under the LGPL license. It will tell which browser, version and operating system you (the visitor) are using. It also detects bots and the Flash plugin.
JavaScript browser sniffers are widely used because of the incompatibilities between browsers. Different browsers have different ways understanding the same code written by Javascript. As a result, different browsers will display the same page differently. Javascript browser sniffers detect what web browser a user is working with so as to ensure consistent display of content.
Homework 1: hiThere.html
So easy ~ 赵老师再也不用担心我的学习= =
Homework 2: function.html
简单的js运算操作,添加
简单的js函数实现。代码段如下:
Homework 3: popups.html
根据弹出框的输入重定向页面,修改页面的location属性。代码见askName()函数。这里需要注意如果简单的将location改为“baidu.com”是无法跳转的,因为默认href为相对路径。输入前需要加上http等协议名。
当然,为了简化用户操作,我在函数中添加了自动的验证,即使输入不带协议头的路径,也可以正确跳转。
the Lemon 后面添加 return 就可以了。
这里的status bar其实有点过期啊,我的电脑上只有chrome和firefox。结果网上查询的结果是
The new Firefox Status Bar only shows page loading activity and link previews. When neither of those are needed it simply disappears.The old Status Bar is dead, long live Status-4-Evar!
There’s no status bar in Chrome. The old toolstrip(on the bottom part of the browser) is eliminated in current versions of Chrome. Maybe you can try the switch but I guess it’s virtually useless since no current extensions now utilize that part of the UI.
郁闷死了==卡了半天,最后我在linux上安装了一个IE6,终于在左下角看到了status bar。真的是在linux上安装的,有图有真相!(statusbar.png)
Homework 4: objects.html
简单的全局数组变量操作var HolidayList = [ ];
2&3&4:简单的js类操作。代码如下:
Homework 5: wizardForm.html
检测年龄并且限制年龄的大小。检测数字主要使用js自带的正则表达式。检测大小用eval进行数字之间的比较。
checkSubmit()阻塞提交其实与其返回值有关。如果返回true,表单会继续提交,返回false则停止提交。这种特性正好可以用于上面的检测函数。通过检测则提交,否则不提交。详细可见checkSubmit()函数。
另外,同样添加了其他几个测试函数checkName,checkID,限制输入值的字符。
JavaScript Browser Sniffer is a browser identifier written in JavaScript (EcmaScript) and released under the LGPL license. It will tell which browser, version and operating system you (the visitor) are using. It also detects bots and the Flash plugin.
JavaScript browser sniffers are widely used because of the incompatibilities between browsers. Different browsers have different ways understanding the same code written by Javascript. As a result, different browsers will display the same page differently. Javascript browser sniffers detect what web browser a user is working with so as to ensure consistent display of content.
Homework 1: hiThere.html
So easy ~ 赵老师再也不用担心我的学习= =
Homework 2: function.html
简单的js运算操作,添加
result = result * 2;即可
简单的js函数实现。代码段如下:
function StrCatenate(astr, bstr) { cstr = astr+" != "+bstr; return cstr; }
Homework 3: popups.html
根据弹出框的输入重定向页面,修改页面的location属性。代码见askName()函数。这里需要注意如果简单的将location改为“baidu.com”是无法跳转的,因为默认href为相对路径。输入前需要加上http等协议名。
当然,为了简化用户操作,我在函数中添加了自动的验证,即使输入不带协议头的路径,也可以正确跳转。
the Lemon 后面添加 return 就可以了。
这里的status bar其实有点过期啊,我的电脑上只有chrome和firefox。结果网上查询的结果是
The new Firefox Status Bar only shows page loading activity and link previews. When neither of those are needed it simply disappears.The old Status Bar is dead, long live Status-4-Evar!
There’s no status bar in Chrome. The old toolstrip(on the bottom part of the browser) is eliminated in current versions of Chrome. Maybe you can try the switch but I guess it’s virtually useless since no current extensions now utilize that part of the UI.
郁闷死了==卡了半天,最后我在linux上安装了一个IE6,终于在左下角看到了status bar。真的是在linux上安装的,有图有真相!(statusbar.png)
Homework 4: objects.html
简单的全局数组变量操作var HolidayList = [ ];
2&3&4:简单的js类操作。代码如下:
function makeHoliday(dest, dur, cost) { hol = new Holiday(dest, dur, cost); HolidayList.push(hol); }
function outputObject(anObject) { for (f in anObject) { document.write(f + " = " + anObject[f] + "<br />"); } }
Homework 5: wizardForm.html
检测年龄并且限制年龄的大小。检测数字主要使用js自带的正则表达式。检测大小用eval进行数字之间的比较。
checkSubmit()阻塞提交其实与其返回值有关。如果返回true,表单会继续提交,返回false则停止提交。这种特性正好可以用于上面的检测函数。通过检测则提交,否则不提交。详细可见checkSubmit()函数。
另外,同样添加了其他几个测试函数checkName,checkID,限制输入值的字符。
function checkAge(q) { var reg = /^\d+$/; if (!reg.test(q.Personal_Age.value)) { return false; } if(eval(q.Personal_Age.value)<=5 || eval(q.Personal_Age.value)>=150) { return false; } return true; }
相关文章推荐
- android intent 传递list或者对象
- C# 获取CPU信息
- 拍照打开本地图库裁剪加上传
- Android中TabActivity使用范例
- Sqoop全量和增量导入数据到Oracle数据库
- 文章标题
- Android min, max, targetSDK详解
- 第二章:hadoop2+HA+Zookeeper QJM集群搭建实验
- 数据结构、算法与应用 (C++描述) 第二版 1.10
- java--三目运算符 类型自动提升
- enum 实质分析
- 车段子项目-SSH上传文件
- jquery实现九宫格大转盘抽奖
- ubuntu compile surfGPU
- Android dumpsys 命令解析
- [Android] ImageView.ScaleType设置图解
- xUtils框架的介绍
- 第一章:hadoop1-hdfs完全分布式模式实验
- Spark脚本调用
- 作为一个前端工程师的2015年度学习计划