天天看点

javascript—其他

  window.onload = function () {   

            //json中的function中的this只json对象本身            

            var json = { name: 'abc', age: 12, fn: function () { return this.name; } };           

            alert(arr[0].name);

        }

js操作属性的方法

1.txt1.value='111';

2.txt1['value']='111';

第二种特别用法

function settext(name)

{

txt1[name]='111';

}

3.dom

getattribute(名称)

setattribute(名称,值)

removeattribute(名称)

 //阻止右键菜单

        document.oncontextmenu = function () {

            return false;

        };

offset属性在运动框架中border的bug

clientx,clienty是可视窗口的坐标位置加scrolltop scrollleft