Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Ie8 will has some problem. #29

Open
FiShelly opened this issue Nov 6, 2019 · 0 comments
Open

In Ie8 will has some problem. #29

FiShelly opened this issue Nov 6, 2019 · 0 comments

Comments

@FiShelly
Copy link

FiShelly commented Nov 6, 2019

MDS tell us:
The innerHTML property is read-only on the col, colGroup, frameSet, html, head, style, table, tBody, tFoot, tHead, title, and tr objects.

so:

The insertStyle function will get error in Ie8. By the way, document.head in Ie8 will get undefined.

solve:

function insertStyle (css) {
    if (!css) return;
  
    if (typeof (window) == 'undefined') return;

    var style = document.createElement('style');

    if ('styleSheet' in style) {  // to compatible IE8
        style = document.createElement('div');
        style.innerHTML = 'x<style>'+css+'</style>';
        style = style.lastChild;
    } else {
        style.innerHTML = css;
    }
    var head = document.getElementsByTagName('head')[0];
    head.appendChild(style);
    return css;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant