views:

47

answers:

3

I realize that most browsers block window resizing but was wondering that since I am the parents of this newly opened window, would I have any priveleges over sizing it not just on the Open but after?

I am not trying to annoy users either :) I specifically need to keep 2 windows in sync (Same size).

thanks!

A: 

Yes, you could set the feature variable for the window to be resizable. Keep the 2nd parameter, window name, the same. The opened window will get updated.

Take a look here: Link pretty much all the functionality of window.open is described in that article.

So, something like:

window.open ("www.example.com", "mywindow","width:100,height:100");

//something happens here, so you need to resize the window

window.open ("www.example.com", "mywindow","width:250,height:250");
Dimskiy
The point is that I need to resize the window using javascript.
Mike
Basically something like this: winHandle = window.open(.......);
Mike
winHandle.resizeTo(600,400).. except the resizeTo doenst work in most browsers. If i can get this to work in at least FF and IE, it'd be a start.
Mike
@Mike - I believe this could work. The 2nd parameter in .open() is window name. If you keep this name the same and open another window, the new content will open in already opened window (with that name). Give it a new height and width and open it again. (I don't know what your requirements are, though).
Dimskiy
+1  A: 

Yes, you have control, here is the example from this site:

http://www.javascriptkit.com/javatutors/advwin4.shtml

<script type="text/javascript">
var mylocation="../index.shtml"
var winheight=100
var winsize=100
var x=5

function go(){
  win2=window.open("","","scrollbars")

  if (!document.layers&&!document.all){
    win2.location=mylocation
    return
  }

  win2.resizeTo(100,100)
  win2.moveTo(0,0)
  go2()
}

function go2(){
  if (winheight>=screen.availHeight-3)
  x=0
  win2.resizeBy(5,x)
  winheight+=5
  winsize+=5

  if (winsize>=screen.width-5){
    win2.location=mylocation
    winheight=100
    winsize=100
    x=5
    return
  }

  setTimeout("go2()",50)
}

</script>
<a href="javascript:go()" onMouseover="window.status='open window';return true" onMouseout="window.status=''" >Open window</a>
Romario
Well, I guess it was just my luck that I happened to test in Opera and Chrome - the 2 browsers where this doesn't work :)
Mike
anyone know of a way for chrome and opera to respect this? (I'm assuming they made the "don't annoy the user" decision and disabled this functionality)
Mike
Try reading this site: http://www.howtocreate.co.uk/perfectPopups.html - it has a lot of related info - different browsers, resizing and repositioning
Romario
A: 

The second parameter of the window.open method allows you to specify a window name, so I presume you would be able to resize the window using JavaScript, referencing the window by name, after the window has been opened, yes.

I'm not too hot on JavaScript, so unable to provide a written example off-hand, but in theory it should be possible.

Martin Bean