The javascript “resizeTo” function not working in

2020-01-27 07:34发布

问题:

The resizeTo (that allows setting a new height/width value) function works great on Firefox and Internet Explorer and doesn't work at all on Chrome and Opera.

Is there another function that does the same and works on all the browsers?

Thank you,

Regards

回答1:

No, there isn't another function.

The resizeTo method is disabled by default in several browsers, and I know that it can also be manually disabled in Firefox.

It has been widely misused, so most browser vendors feel that it should be disabled, or at least a user controllable option.



回答2:

On my way it isn't possible to resize the window when it is on top-level. (so not a pop-up)

And i think that chrome got it right by not allowing top level windows to be resized.

You can solve it:

Resizing won't work for top-level tabs, and when you open sample.htm it's opened as a top-level tab. If you instead opened it as a pop-up (for example using window.open with a width and a height set), resizeTo should work.



回答3:

Because many webmasters have made a bad use of pop-ups and resizing, some uncompromising browser manufacturers hopelessly just disable these functions. Other more respectful manufacturers leave them as optional.