@@ -272,4 +272,57 @@ WeixinJSBridge.invoke('getBrandWCPayRequest', d, function(res){
272
272
});
273
273
});
274
274
})(jQuery);
275
- ```
275
+ ```
276
+
277
+ - [ iOS,Safari浏览器,input等表单focus后fixed元素错位问题] ( https://www.snip2code.com/Snippet/176582/--iOS-Safari----input---focus-fixed----- )
278
+ ``` javascript
279
+ if ( / iPhone| iPod| iPad/ i .test (navigator .userAgent ) ) {
280
+ $ (document ).on (' focus' , ' input, textarea' , function ()
281
+ {
282
+ $ (' header' ).css (" position" , ' absolute' );
283
+ $ (' footer' ).css (" position" , ' absolute' );
284
+
285
+ });
286
+
287
+ $ (document ).on (' blur' , ' input, textarea' , function ()
288
+ {
289
+ $ (' header' ).css (" position" , ' fixed' );
290
+ $ (' footer' ).css (" position" , ' fixed' );
291
+
292
+ });
293
+ }
294
+
295
+ ```
296
+
297
+ - 得到地理位置
298
+ ``` javascript
299
+ function getLocation (callback ){
300
+ if (navigator .geolocation ){
301
+ navigator .geolocation .getCurrentPosition (
302
+ function (p ){
303
+ callback (p .coords .latitude , p .coords .longitude );
304
+ },
305
+ function (e ){
306
+ var msg = e .code + " \n " + e .message ;
307
+ }
308
+ );
309
+ }
310
+ }
311
+ ```
312
+
313
+ - [ rem计算适配] ( http://isux.tencent.com/web-app-rem.html )
314
+ ``` javascript
315
+ (function (doc , win ){
316
+ var docEl = doc .documentElement ,
317
+ resizeEvt = ' orientationchange' in window ? ' orientationchange' : ' resize' ,
318
+ recalc = function (){
319
+ var clientWidth = docEl .clientWidth ;
320
+ if (! clientWidth) return ;
321
+ docEl .style .fontSize = 20 * (clientWidth / 320 ) + ' px' ;
322
+ };
323
+
324
+ if (! doc .addEventListener ) return ;
325
+ win .addEventListener (resizeEvt, recalc, false );
326
+ doc .addEventListener (' DOMContentLoaded' , recalc, false );
327
+ })(document , window );
328
+ ```
0 commit comments