• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Invoking Javascript from SWT code

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing issues in invoking a javascript from the SWT code.
The javascript code is written to initialize the scanner.

I create a new instance of org.eclipse.swt.browser.Browser and
boolean setUrl= htmlBrowser.setUrl(<html file path> ;
setUrl returns true.The HTML file sets some global javascript variables.

boolean result=htmlBrowser.execute("scanner_id=\"<object id=WebScanner classid='clsid:2FB3B04B-DE1A-11D2-9543-00A0C996209D' OnDataEvent(Status)='WebScanner_OnDataEvent(Status)'><param name='allowScriptAccess' value='sameDomain'/> </object>\";");
boolean result1=htmlBrowser.execute("document.body.insertAdjacentHTML('AfterBegin', scanner_id);");

result returns true and result1 returns false.

If i add htmlBrowser.execute("alert('test');"); before result1, then i get result1 also to be true.
The scanner gets initialized properly.

I understand that it is weird,but am clueless on why this happens.
Is there any way to get rid of the alert statement and still get result1 as true??

Any pointers are truly appreciated.

Thanks!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic