0

html.AllowJavaScriptUrls syntax

Referring to this page

http://support.brightsign.biz/hc/en-us/articles/218066307-BrightScript-objects-for-JavaScript-are-not-working

The syntax you suggest for allowing multiple URLs doesn't seem to work:

html.AllowJavaScriptUrls({ all: "local", "http://www.brightsign.biz" })

But that resulted in flashing red LED on the player. Can you really pass multiple comma separated items into an associative array just like that? I would think that an item in an associative array only can take a single value. I assume the two comma separated items associated with the "all" key should be wrapped in an array, or similar.

Furthermore, I tried the following in order to communicate with a test server using port 8080:

html.AllowJavaScriptUrls({ all: "http://192.168.0.21:8080" })

But that resulted in a security error. The only way I can make it work is with the wildcard syntax:

h.AllowJavaScriptUrls({ all: "*" })

4 comments

  • 0
    Avatar
    Lyndon

    Please send your entire script. Do you have an object defined in your script called "html"? Or is your html object called "h"?  In our example, "html" is a rohtmlobject that's been defined. The allowjavascripturls method belonds to the rohtmlwidget object. So, for the two failed calls you tried to work, you would have first created a rohtmlwidget called hmtl.

     

    For example:

     

    html = createobject("roHtmlWidget", rectangle)

    In this example, I assume rectangle is a rotectangle object that you've also defined. 

  • 0
    Avatar
    Jean Michel

    Here's the relevant part of the script.

    dispRect = CreateObject("roRectangle", 0, 0, 1920, 1080)
    h = CreateObject("roHtmlWidget", dispRect)
    serverBase = "http://192.168.0.21:8080"
    h.AllowJavaScriptUrls({ all: "*" }) 'Allows all BS specific JS objects
    h.EnableSecurity(true)
    h.SetURL(serverBase)

    Written this way, it works, but is too "lax" in terms of security settings in my mind. Attempting this results in BS-specific javascript not working resulting in error message relatedf to security

    h.AllowJavaScriptUrls({ all: "http://192.168.0.21:8080" })

    Attempting to list several comma separated locations, as suggested in the original posting, results in "red error flash" on the player; e.g.:

    h.AllowJavaScriptUrls({ all: "local", "http://192.168.0.21:8080" }) 

  • 0
    Avatar
    Lyndon

    This works below. I've log a request to check if this is a type in the documentation or if there's a bug. But, creating an array with the addresses first, and then adding that that array seems to work fine; no crashes. 

     

    js_classes = CreateObject("roAssociativeArray")

    js_classes["all"] = [ "local", "http://www.brihtsign.biz" ]

    h.AllowJavaScriptUrls(js_classes)

  • 0
    Avatar
    Jean Michel

    So I guess we can divide this issue into two separate ones then.

    1. The correct syntax for specifying multiple URLs as parameters to the "all" key in the associative array passed to h.AllowJavaScriptUrls.

    2. Whether a port number can be specified as part of a URL, as I'm trying to do.

    You answer to 1 above seem to indicate that the proper literal syntax for defining an associative array with multiple elements should be:

       h.AllowJavaScriptUrls({ all: ["local", "http://www.brightsign.biz"] })

    Which is what I suspected. I would appreciate if you could confirm this is the proper way to specify this in a literal form.

    As to point 2 above, I have not been able to specify a port number as part of a "sanctioned" URL. Hence, I would like to know; a) can this be done, b) what's the correct syntax for specifying an IP address and port number for such a URL as a parameter to the AllowJavaScriptUrls function.

Please sign in to leave a comment.