没有都能用的,你可以先判断浏览器的类型,然后
id = document.all[5]
id = document.layer[1]很久没有用了,应该是这样

解决方案 »

  1.   

    在Ns6中应该用:
    document.getElementById(elementId)
    ie和Ns6都支持
      

  2.   

    open在netscape中要怎么写?
    mywindow=open(URL,'kk','toolvar=no,location=no,menubar=no,width=650,height=500,scrollbars=yes');
     mywindow.focus();
    我这样怎么错了?
      

  3.   

    Try:
    var mywindow=open(URL,'kk','toolvar=no,location=no,menubar=no,width=650,height=500,scrollbars=yes');
     mywindow.focus();
      

  4.   

    最好在
    URL
    页面里的<body onload="window.focus()">
      

  5.   

    在ie中我用如下javascript:
    function doChangeTree(){
       alert("haha");
    }
    document.onclick = doChangeTree;
    是可以的,
    在netscape6中要怎么使用??
      

  6.   

    Netscape 6 has a unique event model. It combines the Netscape Navigator 4.x event model with that of Internet Explorer. Events in Navigator propagate downwards from the browser window object to the target object. Any object in the hierarchy can capture the event before it reaches the target object. Events in Internet Explorer propagate in the opposite direction. They bubble from the target object towards the browser window object. Any object can process the event on its way up. Netscape 6 supports both directions. The event dives in from the browser window object to the target object and then bubbles back to the window object. You can specify whether you want to intercept the event during its dive (capture phase) or its ascend (bubbling phase).Another advantage of the Netscape 6 event model is the ability to specify more than one action per an event type, similarly to how you do it in Internet Explorer 5.x. Netscape Navigator 4.x supports only one action per an event type. If you want to invoke the function buttonClicked() whenever a button is clicked, you would write its event handler as:
    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>
      

  7.   

    我是想在页面的任何地方点击鼠标
    都出发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中用什么代替?