I am having similar issues from
unable to run an external javascript using a bookmarklet.
But I am executing my JavaScript inside a Java application via injecting script headers into the current DOM loaded via Java application.
This problem seems to occur randomly. Some cases it returns [object HTMLScriptElement]
and other times returns the text...
When I alert()
the object, it returns text!
I have tried return String(hi);
but still no effect.
function returnsomeText(){
var hi = someArray.join(':');
alert(hi); //returns text:text:text:text as expected.
return hi; //returns [object HTMLScriptElement]
}
I am very confused to as what is causing this problem! If JavaScript returns [object HTMLScriptElement]
then my Java application cannot process the text.
This question is in more detail here: