Foreplay: Halo is sleepy, the test sister paper to take an ipad, open a micro-blog, opened the site said you see, micro-blog with browser Click to enlarge the Web page is not adaptive AH (website because there are pictures of God horse, the whole station picture to adapt to all kinds of mobile devices), I woke up, thought I grass this is what function, When people like me who have ipads have seen this feature.
Well, since there's been a problem, start thinking about it---continue to coma for 10 minutes ....
Start: Take the ipad probably looked at, when the micro-Bo opened, in fact, the page is still a little redundant blank width, since made a 80% (estimate) of the visual display area, but still can be useful to move to leave a blank, and then click to enlarge, the page Tile this window, the first thought must not be adjusted my redraw code , but the experience of the exhibition area, it does not need to adjust (I re-adjust the page, listening to the first page rotation, otherwise resize) so resize not bound events, since it is just the ipad Weibo is so, first confirm the ipad Weibo useragent bar And looked at the fruit of a mozilla/5.0 (IPAD; CPU os 5_1_1 like Mac os X applewebkit/534.46 (khtml, like Gecko) mobile/9b206 ipad1,1__weibo__3.5.1__ipad__os5.1.1 roar that's you. The
var iPad = navigator.userAgent.toLowerCase().match(/iPad/i); var isIpadWeibo = null;if(iPad) { var isIpadWeibo = navigator.userAgent.toLowerCase().match(/_weibo_/i);}
So as long as the judgment is Isipadweibo, then I'll bind the event once.
if(isIpadWeibo) { $(window).on(‘resize‘, function() { //js调整图片自适应代码 }); }
Problem solving.