Is it possible to achieve compatibility with ie7's document.createElement () through the chrome plug-in?

if you want to open an old website in a newer browser, the main reason why you can"t open it is that there is such a code

.
document.createElement("<div class="class"></div>");

what"s more, there is such a

.
document.createElement("<div class="class"><div><div></div></div></div>");

to achieve compatibility, you can also replace document.createElement ()

.

how can I make sure this replacement works?


rewrite document.createElement and then parse it yourself, which is not recommended.

var original_fn = document.createElement
document.createElement = function(name) {
    if (/^\w+$/.test(name)) {
        return original_fn.call(document, name)
    }
    // 
    var div = original_fn.call(document, 'div')
    div.innerHTML = name
    return div.firstChild
}
Menu