How to move and resize the browser's window in Opera and Chrome?
Asked Answered
S

1

4

I was looking for a way to resize and move the browser's window and I've found these:
self.resizeTo(w, h) and self.moveTo(x, y) - this seems to work perfectly, but only in Firefox and IE (tested with IE8, I don't know how it works in the previous versions). How can I force the same behavior (resizing and moving) in Opera and Chrome? In these browsers the above solution does not work at all. Just nothing happens and nothing appears in the error console.

Sneaky answered 7/10, 2010 at 17:17 Comment(1)
Note that resize/move may be disabled even for pop-ups on Firefox. Mucking around with window positioning is widely regarded as obnoxious and blocked for this reason.Luminesce
R
3

In Opera and Chrome you can use window.resizeTo(w,h); but it won't affect maximized tabs (so you can only move and resize popups).

Resa answered 7/10, 2010 at 17:57 Comment(6)
Thank you for your answer. I've tried it and it doesn't work indeed, so you're right, it will probably work only in popups. That's not what I expected. Thank you anyway. If I won't get any better answer soon, I will accept your one.Sneaky
@rhino: It doesn't work in IE when tabs are enabled either. You simply can't achieve what you want reliably these days.Frijol
@Tim Down: I don't know which version of IE are you talking about, but on my IE8 with tabs enabled everything works just like in Firefox - I can freely resize and move the window by using JS.Sneaky
@rhino: I'm using IE 7. It works when there's only one tab but not if there's more than one.Frijol
You're right, I haven't tried it before. Indeed, if there's more than one tab, just nothing happens.Sneaky
Note that Opera also has two preferences (under content - javascript preferences) named "Allow moving of windows" and "Allow resizing of windows". If these are disabled by the user there is no way the script can get around it.Nittygritty

© 2022 - 2024 — McMap. All rights reserved.