function refreshMainFrame(url)
{
parent.main.document.location = url;
}
if (document.anchors(0))
{
refreshMainFrame(document.anchors(0).href);
}这段JS报
document.anchors is not a function
[Break on this error] if (document.anchors(0))  function   out(e)   
  {   
var e = e || event;
    var   oObj   =   e.srcElement   ||   e.target;   
  
  var   oTr   =   oObj.parentNode;   
  if(!oTr.tag)   
  oTr.className   =   "out";   
 
  }
这段JS报
event is not defined
[Break on this error] var e = e || event; 找了半天没找出哪里的问题,哪位帮我看下!谢谢!

解决方案 »

  1.   

    上面一个这样试试
    anchors[0]下面要将event作为参数传入,这样调用out(event)
      

  2.   

    不行呀,那样又报e is undefined
      

  3.   

    1。anchors[0]
    2。var e = e || window.event;
      

  4.   

    anchors is not defined
    [Break on this error] if (anchors(0))e is undefined
    [Break on this error] var oObj = e.srcElement || e.target; 
      

  5.   

    function   out()   
      {   
    var e = getEvent();
      var   oObj   =   e.srcElement   ||   e.target;   
      
      var   oTr   =   oObj.parentNode;   
      if(!oTr.tag)   
      oTr.className   =   "out";   
     
      }   
        

      function getEvent()
    {     //同时兼容ie和ff的写法
     if(document.all)    return window.event;       
     func=getEvent.caller;           
     while(func!=null){   
     var arg0=func.arguments[0];
     if(arg0){
     if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){   
     return arg0;
     }
     }
     func=func.caller;
     }
     return null;
    }
    这样写着,第二个问题解决了,但第一个还是没解决。
      

  6.   

    document.anchors["anchorID" ]应该可以吧
      

  7.   

    试了下,就是要用方括号啊,没有报错,另外,每个a标签要定义name属性的
        if (document.anchors[0])
        {
            refreshMainFrame(document.anchors[0].href);
        }
      

  8.   

    楼主这个需要传值的,不是随便定义的,比如out(this);
    在out函数中才可以function out(obj){
       obj.srcElement   
    }
    之类的