Home > Web Front-end > JS Tutorial > Solution for all IE series to support Bootstrap_javascript skills

Solution for all IE series to support Bootstrap_javascript skills

WBOY
Release: 2016-05-16 15:36:08
Original
1128 people have browsed it

I recently made a Web website. I always thought bootstrap was very good. This time I used bootstrap3. There is no problem in chrome, firefox, safari, opera, 360 browser (speed mode), Sogou browser and other browsers. However, I found that the styles could not be displayed under IE8 and IE11, and then searched various Baidu, and finally solved the problem with the help of a netizen’s post. The solution is summarized as follows:

First you need to make sure there is a DOCTYPE declaration at the beginning of your HTML page. DOCTYPE tells the browser what HTML or XHTML specification to use to parse HTML documents, specifically affecting:

Constraint rules for marking attributes and properties
It has an impact on the browser’s rendering mode. Different rendering modes will affect the browser’s parsing of CSS code and even JavaScript scripts
DOCTYPE is very critical. The current best practice is to type in the first line of the HTML document:

<!DOCTYPE html>
Copy after login

The master’s post summarized several reasons for searching for bootstrap. First of all, Bootstrap3 was developed with the principle of mobile devices first, so the reasons may be as follows:

1. The remote address is not called correctly

That is, as long as it is IE9 or below, two special js are called

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
 <script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
 <script src="http://apps.bdimg.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
Copy after login

But I tested and found that just using the above js file is not feasible,

2. The calling method is incorrect

Do not use file:// or @import forms to reference respond.min.js or respond.js or css files

3. Mark the content of the browser (use meta tags to adjust the rendering method of the browser)

bootstrap does not support IE compatibility mode. In order to allow IE browser to run the latest rendering mode, the following tags will be added to the page

IE=edge means that the latest kernel of IE is forced to be used. chrome=1 means that if the browser plug-in Google Chrome Frame for IE6/7/8 and other versions is installed (it can make the user's browser still have the menu and interface of IE, but the user When browsing the web, the Chrome browser kernel is actually used), then the Chrome kernel is used for rendering. For a detailed explanation of this meta tag, please refer to the excellent answers on StackOverflow. For an expert explanation of the tag in English, please refer to
http://stackoverflow.com/questions/6771258/whats-the-difference-if-meta-http-equiv-x-ua-compatible-content-ie-edge-e
I added a sentence

Then that’s it
The kernel controls the Meta tag. Because the current domestic mainstream browsers are dual-core, the meta tag is added to tell the browser which kernel to use to render the page

4.IE8 does not support several properties of container

IE8 does not fully support the use of box-sizing: border-box with min-width, max-width, min-height or max-height. Therefore, the container class in bootstrap v3.0.1 is no longer Use max-width.

5. Problems caused by the order in which JS and CSS are introduced

Must quote css first and then quote js

<link rel="stylesheet" type="text/css" href="bootstrap.min.css" media="screen"/>
<script type="text/javascript" src="js/respond.min.js"></script>



Copy after login

6. There are blank lines before and after DOCTYPE


It doesn’t work if there are spaces here, you have to remove them

7. You can also manually modify bootstrap.css
If you are using bootstrap2.1.1, modifying navbar-inner{ filter:none} can solve the problem. If you are using version 3.0, this code is no longer available. For details, please see the link
http://stackoverflow.com/questions/12460190/bootstrap-navbar-does-not-show-in-ie8

8. Use quirks mode (compatibility mode)

When defining a web page, the mode that is backward compatible with old browsers is quirks mode, and the corresponding "standard mode" is standard mode. Specifically, write as before
http://www.w3.org/TR/html4/strict.dtd">
I’ve tested this and it doesn’t work

Finally, I passed the test under IE11, but when I tested under IE8, I found a problem that placeholder is not supported

The following is how to solve the problem of IE supporting placeholder
The jquery cited in this article is 1.11.1 and passed the test. First quote jquery

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
Copy after login

You can also use other jquery versions
Then introduce
The download address of the jquery.placeholder.js filehttps://github.com/mathiasbynens/jquery-placeholder
Then add the code to the file

<script type="text/javascript">
  $(function () {
    // Invoke the plugin
    $('input, textarea').placeholder();
  });
</script>
Copy after login

The above IE6, 7, 8, 9, 10, 11, chrome, firefox, safari, opera, 360 browser (speed mode), Sogou browser test passed, only IE5.5 does not seem feasible, in short the problem is solved At this point, the evil IE6 - just call it soy sauce

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template