开发者

Can I change a non-resizable existing browser window with Javascript to be resizable?

Simple question, I have a window that was opened with this code

window.开发者_Python百科open(URL, windowName, 'resizable=no');

I know I can control size and position programmatically after it's loaded but how do I make it simply reziable again? is there any way to override it?

(NOTE: I have no access to modify the opening code, but have full access to the child window code)


A hack can be this:

window.open(window.location.href, document.title, 'resizable=yes');
window.close();

but it cause your window open a new window and close itself that is not a good UX


You can resize the child window like this:

self.resizeTo(width, height);

As for making the child window resizable again, I don't think you can. The parent window has control of the child.


No, whether a window is resizable is determined when it is opened. Changing this flag after the fact isn't possible. Depending on your goal opening a new (resizable) child window and closing the old one might be an option, I don't think there are any alternatives.


I can't find it in w3c site so this might be deprecated, but window.setResizable(true) should set it's own window resizeable.

Give it a try, check the link for more information on the restrictions.

The method is also listed here.

Of course that, having control over the child, you could also create a new child from it I guess, as a last resort.


var win = window.open(URL, windowName, 'resizable=no');
win.resizeTo(*yourWidth*, *yourHeight*);

you can use resizeTo to your width and height to change the window size

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜