tags:

views:

51

answers:

3

Hi All,

I have seen many examples on using javascript to resize a browser window, but for me they all fail to perform that function in IE. I include my code to see if anything is wrong with it that I just don't see. The code works great in FF but that is not used at my location.

I am no javaScript expert, but I am no slouch either. If I were new to javaScript I would be hating it. I'm sure it has something to do with IE but I cannot explain it.

Any help would be great.

CODE:

  //window.sizeToContent();
  window.resizeTo(700, 700);

I read in the docs that sizeToContent will not work in IE but resize should. It is an incredibly simple statement.

A: 

I did some testing in IE9 beta (that's the only version of IE that I have on this machine), and it seems that window.resizeTo does not work on the initial page load. It does work if you refresh the page. Also, it does work if you delay its execution:

setTimeout(function() {
    window.resizeTo(200, 200);
}, 2000);  

(at least in IE9 beta)

Šime Vidas
A: 

You won't be able to resize the window reliably with JavaScript. It's not possible in IE 7 with tabbed browsing enabled. It's also potentially annoying for the user.

Tim Down
It is absolute annoying, but that's not an answer...
Henrik
@Henrik: How is it not an answer? I'm saying you can't do it in IE 7, which is popular enough not to be ignored, so in general it can't be done. Coupled with the fact that if you resize the window without the user triggering the action then it's going to be annoying, that adds up to good reasons not to even attempt it.
Tim Down
A: 

This works for me in Internet explorer 8

<html>
<head>
</head>
<body>
  <h1>Resized</h1>

<script>
  window.resizeTo(400,400);
</script>
</body>

alt text

Henrik