Study/Java

java SWT browser javascript call and receive

LoonyHyun 2014. 3. 4. 15:58
반응형

SWT browser 에서 값 가져오기


final Browser browser = new Browser(parent, SWT.NONE);

browser.setJavascriptEnabled(true);

browser.addProgressListener(new ProgressAdapter() {

  public void completed(ProgressEvent event) {

    String bodyHTML = (String) browser.evaluate("return document.body;");

  }

});


SWT browser 의 javascript 실행하기


final Browser browser = new Browser(parent, SWT.NONE);

browser.setJavascriptEnabled(true);

browser.addProgressListener(new ProgressAdapter() {

  public void completed(ProgressEvent event) {

    browser.execute("alert('HELLO WORLD!');");

  }

});