This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes javascript inside java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript inside java" Watch "javascript inside java" New topic
Author

javascript inside java

christine clarin
Ranch Hand

Joined: Feb 05, 2005
Posts: 106
hello, i am using javascript inside java, that is i have a swt browser and i just use browser.execute ("<javascript code>"); i have this problem though, i have this string in java which i want to pass to my javascript string to be executed in browser.execute ("<javascript code>"), how do i do this? for example i have:

void main () {
Browser browser;
String x = "hello";

String commandToRun = "document.write ('hello');\r\n";
browser.execute (commandToRun);
}

what if i want my commandToRun be equal to "document.write (x)" but still, x would be a String holding the value "hello"? how do i insert my java String into my javascript? thanks!!!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
place script tags around the code you want to execute

Are you asking how to append to a string with Java or placing the Java String into a JavaScript string?

Eric
 
 
subject: javascript inside java