webview突出显示无法正常工作

时间:2016-04-07 09:50:32

标签: javascript android webview

将此代码加载到webView后:

 String fun = "javascript:function getTextPage(){" +

            "    if(document.caretRangeFromPoint){" +
            "       var caretRangeStart = document.caretRangeFromPoint(0, 0);\n" +
            "       var caretRangeEnd = document.caretRangeFromPoint(window.innerWidth, window.innerHeight);\n" +
            "    } else {\n" +
            "        return null;\n" +
            "    }" +
            "    var range = document.createRange();\n" +
            "    range.setStart(caretRangeStart.startContainer, caretRangeStart.startOffset);\n" +
            "    range.setEnd(caretRangeEnd.endContainer, caretRangeEnd.endOffset);\n" +
            "    alert(range.toString());" +
            "};";
    loadUrl(fun);
    loadUrl("javascript:getTextPage()");

方法 findAll() findAllAsync()查找文字但不高于此

0 个答案:

没有答案