There are many compatibility problems with IE browser
Master the skill, no longer afraid
Open the homepage of the website with IE browser, why does the homepage display the mobile page?
Note: the current version of ie browser is IE8 and below
Here is the code in CheckMobile.java file (before compilation), as follows:
JAVA code block, as follows:
...Partial ellipsis...
package com.fh.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Check whether it is mobile login
*
*/
public class CheckMobile {
// \b Is word boundary(Two in a row(Alphabetic and non alphabetic characters) Logical separation between),
// The string will be transcoded once at compile time, so it is "\b"
// \B Is the logical interval within the word(The logical interval between successive alphabetic characters)
static String phoneReg = "\\b(ip(hone|od)|android|opera m(ob|in)i"
+ "|windows (phone|ce)|blackberry"
+ "|s(ymbian|eries60|amsung)|p(laybook|alm|rofile/midp"
+ "|laystation portable)|nokia|fennec|htc[-_]"
+ "|mobile|up.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\\b";
static String tableReg = "\\b(ipad|tablet|(Nexus 7)|up.browser"
+ "|[1-4][0-9]{2}x[1-4][0-9]{2})\\b";
// Mobile device regular matching: mobile terminal, tablet
static Pattern phonePat = Pattern.compile(phoneReg,
Pattern.CASE_INSENSITIVE);
static Pattern tablePat = Pattern.compile(tableReg,
Pattern.CASE_INSENSITIVE);
/**
* Detect whether it is mobile device access
*
* @Title: check
* @Date : 2014-7-7 01:29:07 PM
* @param userAgent
* Browser identity
* @return true:Mobile device access, false: pc access
*/
public static boolean check(String userAgent) {
if (null == userAgent) {
userAgent = "";
}
// matching
Matcher matcherPhone = phonePat.matcher(userAgent);
Matcher matcherTable = tablePat.matcher(userAgent);
boolean flag_table =matcherTable.find();
//Under system.out.println (flag_table); / / IE8, return the result: true
//boolean flag_table2 =matcherTable.find(); / / Note: compare the results before and after
//Under system.out.println (flag_table2); / / IE8, return the result: false
boolean flag_Phone =matcherPhone.find();
//Under system.out.println (flag_phone); / / IE8, return the result: false
//boolean flag_Phone2 =matcherPhone.find();
//Under system.out.println (flag_phone2); / / IE8, return the result: false
if ( flag_Phone ) {
return true;
} else {
if ( flag_table ){
return true;}
}
return false;
}
}
...Partial ellipsis...
Be careful:
Through the code comment section above, after testing, we found that:
The same code "matcherTable.find()", after the "System.out.println(flag_table)" printing operation, the value is changed to false, and then under ie8, the front page of the PC can be displayed normally;
On the contrary, if all the matcherTable.find() printing operations are cancelled or commented out, the return value of matcherTable.find() will always be true, that is to say, ie8 is a mobile device, so the home page of the mobile terminal is displayed;
This problem is really wonderful, and no other solution can be found for the time being;
Interim solutions:
It's OK to perform the "system. Out. Println (flag" table) "printing operation. But it's not the solution after all.
In addition, in the compatibility mode of 360 browser, because the IE kernel selected by the user's browser settings is different, the display effect will also be different. For specific demonstration, we will omit it here...