Home > Web Front-end > JS Tutorial > javascript browser judgment binding event arguments conversion array array traversal_javascript skills

javascript browser judgment binding event arguments conversion array array traversal_javascript skills

WBOY
Release: 2016-05-16 18:50:37
Original
880 people have browsed it
复制代码 代码如下:

var $d = document;

function $i(s){return $d.getElementById(s);}
var _jsc={}
_jsc.client=(function(){
var t={};
var b=navigator.userAgent.toLowerCase();
t.isOpera=(b.indexOf('opera')>-1)
t.isIE=(b.indexOf('msie')>-1)
t.isFF=(!t.isOpera&&!t.isIE&&b.indexOf("firefox")>-1);
return t;

})()
_jsc.util=(function(){
var t={}
t.addEvent=function(o,e,f){
if(_jsc.client.isIE){
o.attachEvent("on" e,f)
}else{
o.addEventListener(e,f,fasle);
}
return true
}
return t;
})();
//window.onload=function(){_jsc.util.addEvent(document,"click",showMsg("z","d"))}
_jsc.util.addEvent(document,"click",function(){showMsg("a","b")})

function showMsg()
{
//alert(typeof arguments)
//var dd=[arguments[0],arguments[1]]
//var o = {a:'aa', b:'bb', c:'cc'};
//var o = {};
o=arguments
o=Array.prototype.slice.call(arguments,0);
for(var p in o)
{
alert(o[p]);
}

循环对象的所有属性:
<script> <br>var o = {a:'aa', b:'bb', c:'cc'}; <br>for(var p in o) <br>{ <br>alert(eval("o." p)); <br>} <br></script>

循环数组的所有元素:

<script> <br>var arr = ['11', '22', '33']; <br>for(var i in arr) <br>{ <br>alert(arr[i]); <br>} <br></script>
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template