Results 1 to 2 of 2

Thread: Accessing global JS variables in a JSSP script

  1. #1
    Junior Member
    Join Date
    Jul 2015
    Posts
    25

    Accessing global JS variables in a JSSP script

    Hi all,

    I've declared some variables to be used by the whole app in a JS page specified as the custom library in the app settings. Works totally fine accessing and mutating them from within pages, sections and so on. Now I'm building a webview section to display these variables in a nice, CSS'd format. Problem is, when I try to print the variables to the webview's html with javascript, it's telling me they aren't declared. Obviously they are, so it's not seeing the variables declared in the app's custom library.

    E.G.:

    lib_myapp.js
    Code:
    var myglobal = "abcd";
    page1_section1.jssp:
    Code:
    <%@ Language=JavaScript %>
    <html>
    <head></head>
    <body>
    <% print(myglobal); %>
    </body>
    Is it even possible to access those variables from the javascript on a JSSP page?

    Thanks.
    Last edited by jmartyr; 2016-01-03 at 23:37.

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,342
    Blog Entries
    22
    Custom library code runs in the client.

    WebViews have their own context although you can use the Lianja system object from any JavaScript that is generated and runs within that context.

    Passing client side data to server pages should be done as parameters that should preferably be base64 encoded and if passing many of them added to an object which is JSON encoded on the client and JSON decoded on the server.

    So to summarize. Considering a Webview is generated remotely it has no direct access to client side JavaScript variables.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us