how to pass an variable from Titanium app.js to webview html

You must Login before you can answer or comment on any questions.

how to pass app.js variable to webview html property?

I'm test marquee effect in webview.

I pass a app.js variable to webview html code.

I use this manner, but It is show wrong code about '" .

Am I have to use evalJS reach purpose?

thank you very much.

var myTxtVariable =" test marquee......";
var marquee = Ti.UI.createWebView({
        width : Regis.screenContentWidth,
        height : 40,
        left : 0,
        bottom : 0,
        html:"<marquee  scrollamount=2 >'"myTxtVariable"'</marquee>",
        backgroundColor : "ccc"
    });
win.add(marquee);

— asked 9 months ago by Chang YuanYu
1 Comment
  • If i not use url:xxx.html , can I use html property to reach? thank you~

    — commented 9 months ago by Chang YuanYu

1 Answer

Accepted Answer

— answered 9 months ago by li xinxin
answer permalink
4 Comments
  • If i not use url:xxx.html , can I use html property to reach? thank you~

    — commented 9 months ago by Chang YuanYu

  • And I'm not use javascript code. is it just use html tag marquee code?

    — commented 9 months ago by Chang YuanYu

  • of course you can .

    declare a var, and set html string to it, then set the var to html of webview like you're doing now.

    note that to join a string please use '+'., like this :

    html:"<marquee  scrollamount=2 >" + myTxtVariable + "</marquee>",

    — commented 9 months ago by li xinxin

  • Show 1 more comment

Your Answer

Think you can help? Login to answer this question!