javascript学习

//函數學習/
isNaN 判断是否数字
parseInt 转换为数字
array.length 数组长度
array.join() 数组转换为字符串
array.join(" ")
array.sort() 数组排序
setTimeout(函数, 时间) javascript定时器
setInterval(函数, 时间) 设置定期间隔
clearInterval(名称) 清除超时和间隔
today.getMonth() 月
today.getDate() 日
today.toLocaleString() 年月日
string.substr(a) 去掉前a个
string.substr(a, b) 去掉前a个, 接着取b个
string.substring(a, b) 取第a+1个到第b个
string.big(), small(), bold(), italics(), strike(), fontsize(5), fontcolor(green)
string.toUpperCase(), toLowerCase()
string.concat(str2) 连接字符串
string+=str2 链接字符串
string.anchor("abc")
string.link("http://...")
string.length
string.search("abc") 搜索字符串
string.indexOf("abc") 前面abc的定位
string.lastIndexOf("abc") 后面abc的定位
string.repace("abc", "def") 只能替换一个?
string.split("abc") 分割, 返回数组
date.getYear(), getMonth(), getDate(), getHours(), getMinutes(), getSeconds(), getDay()
date.setYear(), setMonth() ... ...
Math.PI
Math.random() 0-1随机
Math.floor 舍去小数点后的, -41.2 > -42 41.5 > 41
Math.round 四舍五入
Math.sqrt 平方根, 负数得 NaN
Math.pow(a, b) 乘方, a的b次方
Math.max(a, b)
Math.min(a, b)

屬性/
document.images[0].src
document.links.length
document.anchors.length
document.links[0].protocol
document.links[0].pathname
document.links[0].href
document.bgColor
document.fgColor
document.linkColor
document.title
document.lastModified
document.URL
document.referrer 引用页
window.status
window.history.go(-1)
window.close()
window.print()
window.moveTo(x, y)
window.moveBy(x, y)
window.resizeTo(x, y)
window.resizeBy(x, y)
window.alert(cc)
cc=window.prompt("title", "value")
cc=window.confirm("您觉得好吗?")
navigator对象:
属性
appcodename: Mozilla
appname: Microsoft Internet Explorer
appversion: 4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; Poco 0.31; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
platform: Win32
userAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; Poco 0.31; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
方法
javaEnabled():true

location对象//
location.hash
location.hostname
location.host
location.href
location.port
location.search
location.reload()
///其他/
1. 任何不用var关键字声明的变量都是全局变量, 任何在函数外声明的变量都是全局变量.
2. οnkeypress=if(window.event.keyCode=='100')..... 检测键盘按键
3. 4000 = 4秒
4.input onfocus onblur
<input value="abc" οnfοcus="this.value=(this.value=='abc')?'':this.value;"
οnblur="this.value=(this.value=='')?'abc':this.value;">
5. 返回
<a href="#" οnclick="window.history.go(-1);">返回</a>
6.打开窗口
window.open("xxx.htm", "title", "width=200,height=100,resizable=yes");

7.<a href="#top">top</a>
8.取得select当前选种的option
var i = selectId.selectIndex;
selectId.option[i].text;
selectId.option[i].value;
9.字符串转int
var i = parseInt("123"); 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值