What does $(window).resize do? JQuery Mobile

2020-07-29 17:47发布

问题:

So I had a look at jquery mobile, for my ipad webapp, and I saw this:

http://api.jquery.com/resize/

Which, of course, I'm looking at because of this: how to resize / rezoom webpage in ipad

But the thing is, this window.resize doesn't do a darn thing for me. At least, I was expecting it to re-apply the maximum-scale and minimum-scale values

It does not. Am I missing something here, or is window.resize bunk?

UPDATE I suppose i mean : does the window.resize fire after an orientation change on an ipad, and if so, does it cause the scales -minimum-scale and maximum-scale - to be reset?

回答1:

$(window).resize as per the api doc has two syntaxes: the first one is to bind a function to be executed upon resize, and the second one to trigger the callback to functions that listens to the resize event.

It does not do anything per se except provide you with a way to set up a listener for the event and manually trigger it if needed - so it won't reset any other properties

To the best of my knowledge, ipad orientation changes DO trigger resize events when using safari. However, if your app is using a native uiwebview, it is possible that orientation changes don't trigger it.