Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Passing html from AS3 to Javascript

Explorer ,
May 21, 2013 May 21, 2013

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.

TOPICS
ActionScript
494
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 21, 2013 May 21, 2013
LATEST

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')"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines