汇总一些JS小点使用方法记录
一.相同name获得值
1.获得当前索引:
var index = getElementOrder(Field)-1;//Field传入this
2.获得当前的值:
fm.QuantityMain[index].value//QuantityMain是name;fm是form的name
3.获得tbody及其行数:
var oTBODY = document.all("ItemKindMain").tBodies.item(0);
//ItemKindMain即pageCode是table的id;tBodies是tbody;item(0)是获取第一个
var intCount = oTBODY.rows.length;//获得行数
------------------------------------------------------------------------------------------------------------------------------------------------------------------
二.location.href用法
4.top.location.href=”url” 在顶层页面打开url(跳出框架)
self.location.href=”url” 仅在本页面打开url地址
parent.location.href=”url” 在父窗口打开Url地址
this.location.href=”url” 用法和self的用法一致
5.if (top.location == self.location) 可判断当前location是否为顶层
6.A href="javascript:;"显示为链接的样式,是一个空链接,单击也没什么反应.一般和onclick事件结合使用.href="javascript:void(0)"是一样.
三.通过form的name拿到action,input值,target等信息等信息
7.fm.action=xxx;
8.fm.inputName.value可以赋值,可以拿值;
9.fm.target=xxx可以设置:
_blank | 在新窗口/选项卡中打开。 |
_self | 在同一框架中打开。(默认) |
_parent | 在父框架中打开。 |
_top | 在整个窗口中打开。 |
framename | 在指定的框架中打开。 |
四.事件onfocus、onchange、onpropertychange区别
10.onfocus是获得焦点生效,点击生效
11.onchange是值改变生效,必须在当前的对象之外点击生效,页面加载的时候不生效。
12.onpropertychange是值改变生效,无需点击,在页面加载的时候也会生效。
五.ID的使用
13.一般ID的使用是通过document.getElementById(""),这种用法符合W3C标准。
14.id.innerHTML="XXX";也可以赋值等操作。
posted on 2017-04-26 10:03 West-Cowboy-TY 阅读(282) 评论(0) 编辑 收藏 举报