日期:2014-05-16 浏览次数:20446 次
if(undefined||null){ alert("haha"); }else{ //会走这里 alert("nohaha"); } if(2){//会走这里 alert("haha"); }else{ alert("nohaha"); }
function addNum(i){ i = i + 5; } function test(){ var i = 0; addNum(i); alert(i);//打印出来的值为0 }
<marquee onmouseover="this.stop()" onmouseout="this.start()">跑马灯效果,欢迎大家学习!</marquee>
function goToUrl(){ var s = document.getElementById("toUrl"); if(s.options[s.selectedIndex].value != -1){ //window.location.href="http://www." + s.options[s.selectedIndex].value + ".com"; window.open("http://www." + s.options[s.selectedIndex].value + ".com","_blank"); } } <select onchange="goToUrl();" id="toUrl"> <option value="-1">请选择要去的网站</option> <option value="sina">新浪网</option> <option value="baidu">百度</option> </select>
<body onmouseup="document.selection.empty();" oncontextmenu="return false;" onmousemove="document.selection.empty(); onCopy="document.selection.empty();" onselect="document.selection.empty();">################################################################
<script type="text/javascript"> function mt1(){ alert("1"); } function mt2(){ alert("2"); } function mt3(){ alert("3"); } function init(){ var btn1 = document.getElementById("button1"); if(window.ActiveXObject){ //这是IE浏览器,需要写全 onclick,也不需要false btn1.attachEvent("onclick",mt1); }else{//这是firefox浏览器 btn1.addEventListener("click",mt1,false); } //btn1.addEventListener("click",mt2,false); //btn1.addEventListener("click",mt3,false); } </script> </head> <body onload="init();"> <input type="button" value="button1" id="button1"/> </body>
<script language="javascript"> function selectAll(){ var al = document.getElementById("all"); /*全选功能 if(al.checked == true){ var cbs = document.getElementsByName("cb"); for(var i = 0; i < cbs.length; i++){ cbs[i].checked = true; } }else{ var cbs = document.getElementsByName("cb"); for(var i = 0; i < cbs.length; i++){ cbs[i].checked = false; } } */ //全选功能 var cbs = document.getElementsByName("cb"); for(var i = 0; i < cbs.length; i++){ cbs[i].checked = al.checked; } } </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <p> 全选 <input type="checkbox" name="checkbox2" value="checkbox" id="all" onclick="selectAll();"/> </p> <p> <input type="checkbox" name="cb" value="checkbox" /> <input type="checkbox" name="cb" value="checkbox" /> <input type="checkbox" name="cb" value="checkbox" /> <input type="checkbox" name="cb" value="checkbox" /> <input type="checkbox" name="cb" value="checkbox" /> <input type="checkbox" name="cb" value="checkbox" /> <input type="checkbox" name="cb" value="checkbox" /> <input type="check