线程" main"中的例外情况org.eclipse.swt.SWTException:由于错误800a025e无法完成操作

时间:2014-10-16 06:35:59

标签: java javascript eclipse swt

我正在使用嵌入式浏览器开发一个SWT应用程序,并使用以下函数在浏览器中实现搜索功能。如果我搜索其中包含两个以上字母的单词,这种方法非常有效。如果我搜索1个字母或2个字母,则会抛出错误

线程中的异常" main" org.eclipse.swt.SWTException:由于错误800a025e,无法完成操作。

public void searchNextOccuranceOfWord(String str)
{
    System.out.println("Search next button is pressed");

    str=str.trim();
    String script_finddown= " var supported = false;"+
               "var found = false;"+
               "if (window.find) {"+        // Firefox, Google Chrome, Safari
                   "supported = true;"+
                       // if some content is selected, the start position of the search 
                       // will be the end position of the selection
                   "found = window.find (\""+ str+ "\",false,false,false,false,true,false);return \" found  \"; "+
               "}"+
               "else {"+
                   "if (document.selection && document.selection.createRange) {"+ // Internet Explorer, Opera before version 10.5
                    "var textRange = document.selection.createRange ();"+
                       "if (textRange.findText) {"+   // Internet Explorer
                           "supported = true;"+
                               // if some content is selected, the start position of the search 
                               // will be the position after the start position of the selection
                           "if (textRange.text.length > 0) {"+
                               "textRange.collapse (true);"+
                               "textRange.move (\"character\", 1);"+
                           "}"+

                           "found = textRange.findText (\""+str+ "\",1);"+
                           "if (found) {"+
                               "textRange.select ();return \"found \" ; "+
                           "}"+
                       "}"+
                  "}"+


               "if (supported) {"+
                   "if (!found) {"+
                       "return \" not found\"; "+
                   "}"+
               "}"+
               "else {"+
               "return \" not suppoerted\"; " +
               "}"+
            "} " ;

    //boolean ex = browser.execute("window.find(\"" + str + "\" ,false,false,true,false,true,false )");
    String ex = (String)browser.evaluate(script_finddown);
    System.out.println(ex);
    // TODO Auto-generated method stub

}

我调试了它,发现声明中有问题" textRange.select()"

0 个答案:

没有答案