现在实现一个功能:在窗口最大化后,要重新获取页面控件的位置信息我试着用window.onresize(),但是这个方法调用时机是在window框最大化后执行,这个时候body的内容还没有最大化,也没有显示出来,所以无法获取页面最大化后的空间位置。用window.onresizeend()方法不起作用。
请教各位,有什么方法能实现这个需求?

解决方案 »

  1.   

    状态机~~
    你的页面有2种状态 定义下面的全局变量
    state{  //初始化 flase onload后设置成true
        true:加载完了
        flase:还没有加载完
    }function 获取页面数据(){
      if(state==true){处理操作}
    }onload 事件中 设置完state后 也要调用下 上面的方法作为一个初始化
      

  2.   

    这个问题解决的也能顺便帮我解决个问题了
    我只知道页面首次加载完成可以通过onload事件获取,之后通过非刷新方式想获取加载完成的事件还真不知道。
      

  3.   

    其实我是这样想的,你看看行不。页面最大化的时候肯定有某些特征,即某些数据的改变。通过判断这些数据的改变来判断是否最大化了,如果为true 则获取数据,否则不执行你看行不?
      

  4.   

    所以onload的时候一定要执行下 “获取页面数据”方法
      

  5.   

    没那么麻烦,
    resize事件是在窗口大小发生变化后触发的!另外,IE 的body本身支持resize 事件
    可以在body 元素上直接捆绑 handler--------------------------------------
    Occurs when the size of an object has changed.
    To get the size of an object, use the clientWidth, clientHeight, innerWidth, innerHeight, offsetWidth and offsetHeight properties.    * In Firefox, Opera, Google Chrome and Safari, the onresize event is fired only when the size of the browser window is changed.
        * In Internet Explorer, the onresize event is fired when the size of the browser window or an element is changed.Note: the onresize event is supported by the body, frameset, document and window elements in Firefox, Opera, Google Chrome and Safari. They are identical, they fire when the size of the browser window is changed.----------------------------------------------------
    In HTML:
    <ELEMENT onresize="handler">
    In JavaScript:
    object.onresize = handler; 全浏览器

    object.attachEvent ("onresize", handler); 仅IE 和 Opera

    object.addEventListener ("resize", handler, useCapture); 除IE 外其他浏览器