---
title: "如何让jQuery Mobile应用支持非移动浏览器及IE7+"
author: "flashcloud"
date: "2011-08-09T23:03:21Z"
tags: []
categories: ["Web前端"]
slug: "jquery-mobile-ie7"
draft: false
lastmod: "2011-08-09T23:05:57Z"
id: 1143962
url: "https://flashcloud.iteye.com/blog/1143962"
---

[jQuery Mobile](http://jquerymobile.com/)做得很漂亮，目前已经发布 1.0-beta 2了，标志可用于实际生产环境的日子也不远了。jQuery Mobile的野心非常大，它想一统移动开发，包括：android,iphone,Symbian,Blackbery,webOS。那么有否想过将其用于企业应用开发中，或者让其支持IE呢，是的，已经有人在 jQuery 的论坛中[问过此事了](http://forum.jquery.com/topic/using-jquery-mobile-for-pcs-ie)，得到的答案是Yes。答案也比较简单，参见：[https://gist.github.com/723870](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 = '<!--[if gt IE '+(++v)+']><br><![endif]-->', a[0]); 
		    return v > 4 ? v : !v;
		}());
    	
    	//must either support media queries or be IE7+
    	return $.support.mediaquery || (ie && ie >= 7);
    }
  });
});
```