<!doctype html>
<head>
<script type="text/javascript">
/*
ps:需要注意的是部分的方法是区分大小写的比如Math
00x1 string 字符串对象
length 属性长度
concat(string) 连接两个或者更多个字符串
indexOf('hello',string) 返回出现的字符位置,如没找到返回-1
案例:
var str = "hello world";
alert((str.indexOf("hello")));
//返回1
substr(start,string) 截取函数
tolowercase(string) 转换为小写
touppercase(string) 转换为大写
replace(str1,str2) 字符替换
00x2 日期对象
getyear() 返回年份
案例:
var a = new Date();
document.write(a.getYear());
getFullyear() 返回年份
getMonth() 返回月份
getdate() 返回日期
getday() 返回星期数
gethours() 返回小时数aaaaaaaaa
getseconds() 返回秒数
00x3 数学对象
ceil(num) 大于或等于该书的最小整数
floor(num) 取整
案例:
alert(Math.floor(2.3));
//弹出2
min
max
pow(num)
random() 默认是取[0,1)之间的数
案例:
alert(console.log(Math.random()));
//比如要取5到10之间的任意数那么即如下代码:
alert(console.log(Math.random()*5+5));
pow(num1,num2) 返回num1的num2次方
round(num) 四舍五入
sqrt(num) 开平方根
00x4 数组对象
concat() 返回一个由两个数组合并组成的新数组
join() 返回一个由数组中所有元素连接在一起的string对象
push() 向数组中添加新元素,返回数组的新长度
shift() 删除数组中的第一个元素并且返回该值
unshift() 返回一个数组,在该数组头部插入了指定的元素
sort() 返回一个元素被排序了得array对象
slice() 返回数组中的一个片段
splice() 从数组中删除元素
00x5 浏览器window对象
window.alert(message) //直接弹出警告窗口
window.confirm(message)//弹出信息框,并且有确定取消 confirm英译为:确定、批准
window.prompt(message);//弹出输入框prompt英译为:敏捷、快速
window.close() //关闭窗口
window.print() //打印
】00x1 window子对象-location
ps:这些都跟数组一样在控制台下是可以被看到的
location 可以打印出url信息
host
port
href 地址
search 参数
assign(url) 页面跳转
protocol 协议
案例1:
console.log(window.location);
//可以在控制台下看到一个类似数组的。比如其打印出文件名
案例2:
console.log(window.location.pathname);
//比如url为:http://127.0.0.1/test.html
即打印出:test.html
案例3:
window.location.href="http://www.cnblogs.com/xishaonian/"; //跳转到我的博客园
】00x2 window子对象-navigator
vavigator 浏览器信息,类似http请求
appcodename 内部代码
appname 浏览器名称
language
useragent 用户代理
......
】00x3 window子对象-history
history 历史纪录
forward()
go()
length 历史纪录的数目
】00x4 window子对象-scree
scree 屏幕对象
height
width
avaliheight 可用高度
avaliwidth 可用宽度
*/
console.log(window.scree);
</script>
</script>