denis
denis

Reputation: 189

Font Awesome all.js file not working in ie9

I downloaded the pro fontawesome file to use in my web app. I can't use the CDN. I have inserted the all.js file properly as it is working fine in ie11 and all other browsers. I need it to also work in ie9 though. It does work using the CDN in ie9, but I can't deploy the site using the CDN. Any suggestions?

Upvotes: 0

Views: 533

Answers (1)

Zhi Lv
Zhi Lv

Reputation: 21591

According to your description, I try to download the font awesome files and use in my app. In IE9 browser, when using all.js, it will display the "Unable to get property 'add' of undefined or null reference" error. The issue is related to the IE9 doesn't support classList, so we'll need a polyfill like classList.js. Then, you could use the font awesome file reference, instead of using the CDN reference.

Code like this:

<head>
    <title>Font Awesome 5 Icons</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link href="fontawesome/css/all.css" rel="stylesheet" />
    <script src="classList.min.js"></script> <!--https://cdnjs.cloudflare.com/ajax/libs/classlist/1.2.20171210/classList.min.js-->
    <script src="polyfill.classList.min.js"></script> <!--https://cdn.jsdelivr.net/npm/[email protected]/classList.min.js-->
    <script src="fontawesome/js/all.js"></script>
</head>
<body>

    <h1>fas fa-tty</h1>

    <i class='fas fa-tty'></i>
    <i class='fas fa-tty' style='font-size:24px'></i>
    <i class='fas fa-tty' style='font-size:36px'></i>
    <i class='fas fa-tty' style='font-size:48px;color:red'></i>
    <br>
    <span style="font-size: 3em; color: Tomato;">
        <i class="fas fa-igloo"></i>
    </span>

    <span style="font-size: 48px; color: Dodgerblue;">
        <i class="fas fa-igloo"></i>
    </span>

    <span style="font-size: 3rem;">
        <span style="color: Mediumslateblue;">
            <i class="fas fa-igloo"></i>
        </span>
    </span>
</body>

the result (using F12 change to IE 9):

enter image description here

Upvotes: 1

Related Questions