如何让jQuery Mobile应用支持非移动浏览器及IE7+

阅读更多

      jQuery Mobile做得很漂亮,目前已经发布 1.0-beta 2了,标志可用于实际生产环境的日子也不远了。jQuery Mobile的野心非常大,它想一统移动开发,包括:android,iphone,Symbian,Blackbery,webOS。那么有否想过将其用于企业应用开发中,或者让其支持IE呢,是的,已经有人在 jQuery 的论坛中问过此事了,得到的答案是Yes。答案也比较简单,参见:https://gist.github.com/723870,一断javaScript代码,放在jQuery库和jQuery Mobile库中间:

 

 

//run this script after jQuery loads, but before jQuery Mobile loads

//customize jQuery Mobile to let IE7+ in (Mobile IE)				
$(document).bind("mobileinit", function(){
  $.extend(  $.mobile , {
  	
  //extend gradeA qualifier to include IE7+
    gradeA: function(){    	
    	//IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
		var ie = (function() {
		    var v = 3, div = document.createElement('div'), a = div.all || [];
		    while (div.innerHTML = '', a[0]); 
		    return v > 4 ? v : !v;
		}());
    	
    	//must either support media queries or be IE7+
    	return $.support.mediaquery || (ie && ie >= 7);
    }
  });
});

你可能感兴趣的:(jquery)