Copy link to clipboard
Copied
I am using WebStageView to pass html from AS3 to a Javascript function in a webpage.
I do this like:
var urltext:String = "javascript:setText('aaa','vvv')"
webView.loadURL(urltext);
This successfully calls a function in JS named setText which in turn sets the value of a div or whatever else I want to do.
Here is the problem:
If I want to pass:
var urltext:String = "javascript:setText('<p>aaa</p>','vvv')" the formatted text works fine and I get no errors however,
if I pass it like this:
var txt:String = '<p>aaa</p>';
var urltext:String = ""javascript:setText('+txt+','vvv')" then I get a parse error;
It traces out to look like this:
urltext: javascript:setText('<p>aaaaa</p>
','vvv')
Notice that there is a return after the </p> which is apparently causing the parse error.
I am loading text from a file and passing it via the above call to JS.
In short, is there a way to format the text so it doies not cause the parse error?
Or, is there a better way to pass html strings in a call to Javascript?
ExternalInterface does not seem to work anymore and I am avoiding WebStageViewBridge.
Copy link to clipboard
Copied
Ain't that the way of it..
Came up with a solution Minutes after I posted this problem.
Here it is, just in case:
var urltext:String = "javascript:setText("+com.adobe.serialization.json.JSON.encode(fileText)+",'vvv')"
Find more inspiration, events, and resources on the new Adobe Community
Explore Now