Link to home
Start Free TrialLog in
Avatar of lathashankar
lathashankar

asked on

onload Window resize error

Hi,

 I have a function resizeWin() which i call in the body as:
<body onresize="resizeWin()" onload="javascript:resizeWin()">
 
 So this function is called whenever user tries to resize the window or double clicks on the title bar. I want the window to be size of the 'bodyarea layer' defined in the body. When I double click the title bar it works in some IE version 6 and IE version 6 at home gives error pointing to the resizeWin() function not allowed.

The code I use for resizeWin() is as follows:
function resizeWin() {
var winHeight = 499;
var winWidth = 750;

   //for IE
    if(document.all)
    {
        winHeight=document.all['bodyarea'].offsetHeight;
        winWidth=document.all['bodyarea'].offsetWidth;
       
    }
    //for netscape
    if(document.layers)
    {
     
     winHeight = document.layers['bodyarea'].innerHeight;
     winWidth = document.layers['bodyarea'].innerWidth;
     alert(winHeight);
    }
    window.resizeTo(winWidth+30,winHeight+152);
      //centre the window
      if (window.moveTo) window.moveTo((screen.availWidth-winWidth)/2,(screen.availHeight-winHeight-120)/2);
}

thank you,
Avatar of archrajan
archrajan

<BODY onload="window.resizeTo(newwidth,newheight);"

<HTML>
<HEAD>
<SCRIPT LANGUAGE="Javascript">
function resizeWin()
{
  var winHeight = 499;
  var winWidth = 750;

     self.window.resizeTo(winWidth,winHeight);
     return true;
}
</SCRIPT>
</HEAD>
<BODY Onload="resizeWin()">

</BODY>
</HTML>
Avatar of lathashankar

ASKER

It did not solve the problem. When ever i double click the window and maximize it, I get the following error:

Access denied and line number points to my window.resizeTo line number.

I want the window to be the size i specified in the code and should be resized by user.

thanks
ASKER CERTIFIED SOLUTION
Avatar of rk_radhakrishna
rk_radhakrishna

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes my code works fine in some IE explorer version but in my home computer which has the same IE version it is giving that error which i mentioned,

thanx
check this newer version, which I have given in previous.
Hi,

 I tried your code, it still gives me the same error,

thank you
Hi,

 On resize the window, the window should get back to intial size set by resizewin function. But instead it is going to maximized window with error at the bottom saying: access is denied and the error number points to window.resizeTo line in the resizewin function.

thank you