Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java - Javascript string

Status
Not open for further replies.

Rodie

Programmer
Jun 27, 2004
132
FR
Hi :)

I have a web page that contains an java applet. Inside the web page, a javascript function receives a String from the applet. I can print this string, but not access to the characters of the string (as an array):
alert(mystring[0]); => returns "undefined"

Someone has an idea ??
Thanks for your help
 
Actually I cannot do that in javascript:
var txt = "abcd";
txt[0];
Instead, I found the chatAt() method.

But I have a similar problem with the following piece of code, where "message" is a string I receive from Java, and message = "Info:\t.\t"
Code:
message = message.replace("Info:\t.\t","Info:");
This code generates an exception, only with Firefox (not Internet Explorer) that says:
InternalError: Unable to convert Javascript value Info: . to Java value of type char The blue color corresponds to my "message" variable: "Info:\t.\t"

Have you any idea ?
Thanks a lot
 
It did not work because a Java string is an object. So, to convert Java string into javascript string, I added an empty character like this:

var = java_string + "";
 
oops .. I mean:

var javascript_string = java_string + "";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top