1.使用下面的函数,可以添加任意数量的Load事件的处理函数,而无需担心他们发生冲突。
function addLoadListener(fn)
{
    
if(typeof window.addEventListener !='undefined')
   
{
      window.addEventListener(
'load',fn,false);
   }

   
else if(typeof document.addEventListener !='undefined')
   
{
      document.addEventListener(
'load',fn,false);
   }

   
else if(typeof window.attachEvent !='undefined')
   
{
      window.attachEvent(
'onload',fn);           
   }

   
else
   
{
            var oldfn
=window.onload;
            
if (typeof window.onload !='function')
            
{
                window.onload
=fn;
            }

            
else
            
{
                window.onload 
=function()
                
{
                    oldfn();
                    fn();
                }

            }
              
   }

}

这样就可以随心所欲地增加新的Load事件处理函数了,如下:
addLoadListener(firstfunction);
addLoadListener(secondfunction);

2.Iframe 自适应高度
<iframe  id="content" unselectable="off" name="content" onload="this.height=0;var DframeHeight=(this.Document?this.Document.body.scrollHeight:this.contentDocument.body.offsetHeight);this.height=(DframeHeight>200?DframeHeight:200);"  width="100%"frameborder="0" marginheight="0" marginwidth="0" scrolling="no"  ></iframe>
 测试环境:Windows Server 2003  IE 7.0/Firefox 2.0.0.11

posted on 2007-12-22 20:51  TonyLiu  阅读(345)  评论(0编辑  收藏  举报