没有都能用的,你可以先判断浏览器的类型,然后
id = document.all[5]
id = document.layer[1]很久没有用了,应该是这样
id = document.all[5]
id = document.layer[1]很久没有用了,应该是这样
解决方案 »
- jqeury 添加html 元素后 .click 失效问题
- 求简单正则一条
- 用JAVASCRIPT NEW出来的SELECT,怎么判断它的选中值
- 一个页面复用的滑动门,第一次搞,错误百出,望高手指正!
- ●●●●●●●●●●●●●●●●●●●●●●●●●●●作者这样写的目的是什么呢????
- 怎么换掉一个变量?
- js有没有静态变量,没有的话要怎么办哦
- var i="astsdd:dfdg:dfgag";如何把 "i"以":"为界限,分成3个变量.var i1=astsdd; var i2=dfdg; var i3=dfgad
- 我想在页面状态栏中始终显示中文,请问代码如何写
- 用js删除数据时发现参数自动被修改了,短一点的字符串就可以,郁闷中。。。
- javascript怎么操作数据库?在线等待
- 不明白怎么回事?高手帮帮忙。
document.getElementById(elementId)
ie和Ns6都支持
mywindow=open(URL,'kk','toolvar=no,location=no,menubar=no,width=650,height=500,scrollbars=yes');
mywindow.focus();
我这样怎么错了?
var mywindow=open(URL,'kk','toolvar=no,location=no,menubar=no,width=650,height=500,scrollbars=yes');
mywindow.focus();
URL
页面里的<body onload="window.focus()">
function doChangeTree(){
alert("haha");
}
document.onclick = doChangeTree;
是可以的,
在netscape6中要怎么使用??
onClick = buttonClicked();But what if you want to specify another function to invoke? That's where Netscape 6 kicks in. Netscape 6 introduced a new event concept, the event listener, which is similar to attachEvent() in Internet Explorer 5.x. You attach an event listener to an object. The event listener listens for a specified event, and when the event occurs, the event listener executes a pre-specified action. You can define several event listeners for the same object, and for the same event type. For example, two separate event listeners can listen to a click event for a specific button, and execute two different actions when the event occurs. You add an event listener by the addEventListener() method:
object.addEventListener(eventType, functionCall, downBool)例子:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<TITLE>Event Listener Demo</title>
<STYLE TYPE="text/css">
<!--
FORM.tb {display:inline;}
.twidth{width:100%}
.include{ font-size: 75%; font-family: verdana, arial, helvetica;}
.includebig{font-family: verdana, arial, helvetica;}
.includebig A:link { color: blue; }
.includebig A:visited { color: purple; }
.include A:link { color: blue; }
.include A:visited { color: purple; }
.submitter { font-size: 75%; font-family: verdana, arial, helvetica; }
pre.code {color: #660099; margin-left:5%}
address {text-align: right}
body {background:#FFFFFF; margin-left: 5%; margin-right: 5%}
.WRBannerCenter {margin-left:-5%; margin-right:-5%; margin-top:8px; margin-bottom:8px; text-align:center}-->
</STYLE></HEAD><BODY>
<DIV ID="demoDiv" STYLE="position:relative; left:100px; top:20px; width:120px; height:25px; color:blue; background-color:yellow;">Mouse over me!</DIV>
<SCRIPT LANGUAGE="JavaScript">
<!--
var demoObj;
function init() {
demoObj = document.getElementById("demoDiv");
demoObj.addEventListener("mouseover", colorItTan, false);
demoObj.addEventListener("mouseout", colorItYellow, false);
}function colorItTan() {
demoObj.style.backgroundColor = "tan";
}function colorItYellow() {
demoObj.style.backgroundColor = "yellow";
}onload = init;
// -->
</SCRIPT></BODY>
</HTML>
都出发doChangeTree函数。
再在我的函数中用window.event.srcElement;
得到事件的来源,在处理。上面问题是我自己程序写错了,
我改成:
function doChangeTree()
{
alert('haha');
var targetID, srcElement, targetElement;
srcElement = window.event.srcElement;
if(srcElement.className.substr(0,5) == "LEVEL")
{
targetElement = fnLookupElementRef(srcElement.id)
if (targetElement != null)
{
var sImageSource = srcElement.src;
if (sImageSource.indexOf("empty") == -1)
{
if (targetElement.style.display == "none")
{
targetElement.style.display = "";
srcElement.src = "images/folderopen.gif";
}
else
{
targetElement.style.display = "none";
srcElement.src = "images/folderclosed.gif";
}
}
}
}
}
发现,在netscape中 是window.event.srcElement;出错了。
这个在netscape中用什么代替?