BrightScript objects for JavaScript are not working

If you are using BrightScript objects for JavaScript, you may run into DOM errors like those shown in the following screenshot. To view a console log of BrightScript/JavaScript events, navigate to the Diagnostic Web Server or use the JavaScript console.

DOM_Exception_--_Console_Output.png

Follow the below steps if you are encountering DOM errors.

If using BrightAuthor:connected or BrightAuthor to display HTML

Make sure that you are using BrightAuthor version 4.1 or later. Earlier versions do not have the code that enables BrightScript objects for JavaScript.

Also, ensure that the Enable external data box is checked within the HTML 5 state that is displaying your page.

If displaying HTML using BrightScript

Call the AllowJavaScriptUrls() method on the roHtmlWidget instance you are using to display the page. This method accepts an associative array that maps JavaScript BrightScript classes to the URL(s) that are allowed to use them.

  • An all key indicates that all classes are authorized for the associated URL(s).
  • An asterisk "*" value indicates that all URLs are authorized for the associated BrightScript class.
  • A "local" value indicates that all local pages are authorized for the associated BrightScript class. 

Example: The following will enable all BrightScript classes for all URLs.

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

Example: The following will enable all BrightScript classes for local pages and the BrightSign homepage.

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

Have more questions? Submit a request

1 Comments

  • 0
    Avatar
    Bet

    Thanks for the article!
    I'm trying to use BS objects from a web app that is loaded from an HTML5 widget, I can see at the console a bunch of objects like the roHtmlWidget, but from my app / zone I can't access the instance. Am I missing something?

    Just want to do something like: index.html
    <html>
    <header>
    <script>
    ... some of my own stuff

    roHtmlWidget

    ... some of my own stuff

    </script></header>

Please sign in to leave a comment.
Can't find what you're looking for? Try to
Powered by Zendesk