使fck支持chrome浏览器

发现fck不支持chrome浏览器

查看源代码

修改如下FCKeditor.java

	private boolean isCompatible() {
		String userAgent=request.getHeader("user-agent");
		if(userAgent==null)
			return false;
		userAgent=userAgent.toLowerCase();
		if ((userAgent.indexOf("msie") !=-1) && (userAgent.indexOf("mac") == -1) && (userAgent.indexOf("opera") == -1)) {
			if(retrieveBrowserVersion(userAgent)>=5.5)
				return true;
		}
		else if (userAgent.indexOf("chrome") !=-1){
			if(retrieveBrowserVersion(userAgent)>=5)
				return true;
		}
		else if (userAgent.indexOf("gecko") !=-1){
			if(retrieveBrowserVersion(userAgent)>=20030210)
				return true;
		}
		return false;
	}
	
	private double retrieveBrowserVersion(String userAgent) {
		if(userAgent.indexOf("msie")>-1) {
			String str = userAgent.substring(userAgent.indexOf("msie") + 5);
			return Double.parseDouble(str.substring(0, str.indexOf(";")));
		}
		else if(userAgent.indexOf("chrome")>-1){
			String str = userAgent.substring(userAgent.indexOf("chrome") + 7);
			return Double.parseDouble(str.substring(0, str.indexOf(".")));
		}
		else{
			String str = userAgent.substring(userAgent.indexOf("gecko") + 6);
			return Double.parseDouble(str.substring(0, 8));
		}
	}
 chrome判定要写在gecko前面,这样就能支持chrome 5以上的版本了

你可能感兴趣的:(浏览器,fckeditor,chrome,Opera)