现在的位置: 首页 > 综合 > 正文

几个js问题

2011年10月16日 ⁄ 综合 ⁄ 共 995字 ⁄ 字号 评论关闭

1. window.attachEvent

IE和FF处理不同,如下

另,不能直接使用带参数函数 做为attachEvent的第二个参数,可以使用function(){//这里调用你的需要加参数的js函数}来调用

 

 

if (window.attachEvent)
      window.attachEvent("onresize",function(){ ra_OnPageResize(0)});
else if (window.addEventListener)
      window.addEventListener("resize",function(){ ra_OnPageResize(0)},false);

//FF 里事件是resize

 

2. js调整FrameSet布局cols问题

其实就是直接设置FrameSet.cols (p2f1)就行

今天头晕了,对下面的p1f3.cols设置了半天无效。。

 

p1:

<frameset id=p1f1>

<frame id=p1f2>

<frame src=p2.htm id=p1f3>

</frame>

 

p2:

<frameset id=p2f1>

<frame id=p2f2>

<frame id=p2f3>

</frame>

 

附js:

function Submit_onclick()
        {        
        if (!window.parent.Fset) return;
  str= window.parent.Fset.cols; 
  if (str) str = str.substring(0,str.indexOf(",")); 
  if ((str)&&(str>150)&&(str!="0%"))
         {
         window.parent.Fset.cols="0%,*";        
         }
   else
   {
    window.parent.Fset.cols="200,*"    
   }
       }

 //今天调试跨浏览器发现,ff里不能通过对Frame的ID来直接访问

(IE FF都可以直接通过Frame的Name来访问,但是FrameSet不支持name属性)

因此上面的window.parent.Fset =》window.parent.document.getElementById("Fset");

 

抱歉!评论已关闭.