本文目录一览:
帮我写一段兼容google和IE 的js代码?可以追加分
google和IE效果一样,你说的是FF与IE吧
--------------------
这样用:
EventUtil.addEventHandler
=
function(oTarget,sEventType,fnHandler){
if(oTarget.addEventListener){
oTarget.addEventListener(sEventType,
fnHandler,
false);
}else
if(oTarget.attachEvent){
oTarget.attachEvent("on"
+
sEventType,
fnHandler);
}else{
oTarget["on"
+
sEventType]=fnHandler;}}
EventUtil.removeEventHandler
=
function(oTarget,sEventType,fnHandler){
if(oTarget.addEventListener){
oTarget.removeEventListener(sEventType,fnHandler,false)
}else
if(oTarget.detachEvent){
oTarget.detachEvent("on"
+
sEventType,fnHandler);
}else{
oTarget["on"
+
sEventType]
=
null;}}
function
handleClick(){
alert("单击");
var
oDiv=document.getElementById("mydiv");
EventUtil.removeEventHandler(oDiv,"click",handleClick);}
window.onload=function(){
var
oDiv=document.getElementById("mydiv");
EventUtil.addEventHandler(oDiv,"click",handleClick);}
大家帮我写一段JS代码
var Mystr="123123123aaa123";
if(mystr.indexOf("aaa")!=-1){
var mystr = "b";
}
求帮忙写一段javascript代码
以1班级为例:在“input”里添加一个属性“id”,id=r1
tr style="height:30px;background-color:#fdeaeb;" id="t1"
function bgcolor(){
var r1=document.getElementById("r1").value;
var t1=document.getElementById("t1").value;
if(r1=="一班")
{
t1="tr style="height:30px;background-color:#e7fde0;" id="t1"" ;
}
}