Methods to enable IE9 the following versions to support mainstream HTML5 technologies such as CANVAS,CSS3

Source: Internet
Author: User

1. Preface.
ie6,7,8 support HTML5, looks more difficult, in fact, there is a method is very common, that is, the introduction of JS and CSS, this pluggable introduction to the development is very helpful. For example, here is an example that allows Web pages to support canvas and CSS3.
2. Example.
The following is an example of HTML that displays a red ball in the canvas canvas.
Java code
  1. <! DOCTYPE HTML public "-//W3C//DTD HTML 4.0 transitional//en" >
  2. <HTML>
  3. <HEAD>
  4. <TITLE> fewfwe</title>
  5. <style type="Text/css" >
  6. Body {
  7. Background: #444;
  8. Color: #FFF;
  9. Font-family:helvetica, Arial, Sans-serif;
  10. Text-align:center;
  11. }
  12. #cv {
  13. width:600px; height:400px;
  14. Background: #000;
  15. border-radius:20px;
  16. padding:20px;
  17. margin:20px Auto;
  18. Box-shadow: 0 0 40px #222;
  19. Behavior:url (public/ie-css3.htc);
  20. }
  21. </style>
  22. <script type="Text/javascript" >
  23. function Test () {
  24. var ctx = document.getElementById ("CV"). GetContext ("2d");
  25. Ctx.fillstyle = "#aa0000";
  26. Ctx.beginpath ();
  27. Ctx.arc (0, math.pi*2, true);
  28. Ctx.closepath ();
  29. Ctx.fill ();
  30. }
  31. window.onload = test;
  32. </script>
  33. <body>
  34. <!--[if ie]>
  35. <script src="public/html5.js" type="Text/javascript" ></script>
  36. <script type="Text/javascript" src="public/excanvas.compiled.js" ></script>
  37. <! [endif]-->
  38. <canvas id="CV" ></canvas>
  39. </body>

This example cannot be run in IE8, Firefox can. If you want it to work in ie6,7,8, you need to do two things.
2.1 Add a HTML5 IE Auxiliary js file and a canvas-compatible JS file
This file can be named Html5.js, which is an open source JS file, can be used with ease, it is mainly to solve the 6,7,8 compatible with HTML5 JS problem. The canvas compatible file is named Excanvas.compiled.js, and all the files I have packed in the demo. can be downloaded.
2.2. Add a CSS file and reference it on the page.
The CSS file is named IE-CSS3.HTC, which solves the problem of ie6,7,8, which is compatible with CSS3.
3.demo Downloads.
See annex.
4. Example Run Results
See this picture below. is a red circle that appears above the black canvas.

5. Summary
ie6,7,8 compatibility with other HTML5 technology, in fact, can be modeled as a reference to JS and CSS practices. In this way, the HTML5 on the mobile side of the gallop, clearing the last hint of obstacles.

    • test21.rar  (13.6 KB)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.