8

I don't have an iPhone so am unable to test this myself, but according to a client if he zooms in to more easily click a link, then when the next page loads the page stays zoomed in and the user manually has to zoom out again.

Note that this is NOT a responsive site (it doesn't have a meta width=device-width set).

Is there any way to prevent this? I tried adding a maximum-zoom=1 onload only to remove it seconds later, but that didn't work at all.

When googling the problem all I can find is people having the zoom level go bananas when changing orientation of a webapp - which is not the same problem.

powerbuoy
  • 12,460
  • 7
  • 48
  • 78
  • Could you attach link to your site? – sergdenisov Jul 05 '15 at 17:37
  • Try the solutions at http://stackoverflow.com/questions/2557801/how-do-i-reset-the-scale-zoom-of-a-web-app-on-an-orientation-change-on-the-iphon – Andrew Jul 05 '15 at 18:13
  • @SergeyDenisov the site in question is towejewels.com but I got the impression this happens on all (non responsive at least) sites. – powerbuoy Jul 05 '15 at 21:56
  • @SantaClaus naw that's another problem I mention in the last paragraph. This is just a normal web site - not a web app. – powerbuoy Jul 05 '15 at 21:57
  • @powerbuoy I tried on iPhone 5s (iOS 8.4), works OK, page isn't zoomed on next page. – sergdenisov Jul 06 '15 at 20:04
  • 2
    @SergeyDenisov There are "tabs" (JS content switchers) on the page as well. I'm starting to think the client meant those (and when you click them the page doesn't reload so obviously the zoom lever stays the same..) – powerbuoy Jul 06 '15 at 21:57
  • @powerbuoy it's more like the truth. – sergdenisov Jul 06 '15 at 22:39
  • @powerbuoy what about to apply this solution on tag change? http://stackoverflow.com/questions/2557801/how-do-i-reset-the-scale-zoom-of-a-web-app-on-an-orientation-change-on-the-iphon – sergdenisov Jul 08 '15 at 14:32

2 Answers2

0

Due to security concerns, it is not possible to change the browser's zoom level without the user's consent and manual input. It is possible that you might be able to achieve a similar effect using an active plugin (Flash?), but that is the only way to truly reset the browser's zoom level.

You could, as an alternative, change the browser's CSS zoom with the transform: zoom() attribute (a good SO reference), and make the site appear as if the zoom has reset, but only to an extent. Before production, you may also want to adjust for non-integer zoom levels and cross-browser compatibility. Even so, this CSS implementation probably isn't what you're looking for, since it often only adjusts element styles and font size. You might also use this abbreviated jQuery code to achieve the same effect: $(document.body).css('zoom','150%').

Community
  • 1
  • 1
andrewgu
  • 1,562
  • 14
  • 23
-2

i understand this might be problem of web view. you can simply set

webView.scalesPageToFit = YES;

if above didn't work in your case then you need to do some changes in you code to fit content in webview.

you can look this link it might help you. set content of webview without zooming out

Community
  • 1
  • 1
Nik
  • 1,679
  • 1
  • 20
  • 36