2

我正在尝试在页面上查找一些文本,例如:

function crossBrowserFind() {
    var str = "Hell";
    if (window.find) {        // Firefox, Google Chrome, Safari
        found = window.find(str);
    }else {
        if (document.body.createTextRange) { // Internet Explorer, Opera before version 10.5
            var textRange = document.body.createTextRange();
            if (textRange.findText) {   // Internet Explorer   		
                found = textRange.findText(str);
                if (found) {
                    textRange.select();
                }
            }
        }
    }   			
}

但是在 Microsoft Edge(win10 build 10162)中运行时不支持名为“createTextRange”的函数。

有人知道如何在 Microsoft Edge 中找到文本吗?

4

0 回答 0