resizeBy throwing "Access is denied" exception in IE
I am trying to resize the window in IE. For this, I am using
window.resizeBy(width - document.documentElement.clientWidth, height - document.documentElement.clientHeight);
However, sometimes this fails with an "Access is denied" exception. The way I was handling this was just to use
setTimeout('resizeWindow(' + width + ', ' + height + ')', 200);
if the exception occurs to try again a little later.
The trouble is it is now causing a race condition if the window needs开发者_运维知识库 to be re-sized several times in quick succession.
Does anyone know why the "Access is denied" exception might be being thrown and how to avoid it?
The resize happens in response to the user clicking on a button. On mousedown on the button an event is triggered, which in turn resizes the window. If the user held the button down during the resize IE throws the exception as it does not allow windows to resize while the button is down (presumably for usability reasons). Rapidly toggling the button increased the likelihood that the mouse button would be down while it tried to resize the window.
精彩评论