Contact Us

CATEGORIES

Whoops…Nothing found

Try other keywords in your search

JavaScript in Web Browser Resources

 1 Minute

 1 Like

 1233 Views

Starting from 25.2, it is possible to run JavaScript code directly within the currently loaded Web Resource.

This enables more specialized use cases, for example, you can trigger animations directly from a Cue or a Keyframe.


API Command

 

The API call for this is:

null executeJavaScriptOnCurrentWebResource(string script)

This call needs to be performed for each Layer you want to run the JavaScript command on.


Limitations

 

It's not possible to synchronize animations across multiple instances of the Browser Resource.

This means that in a multi-client setup—where the Web Browser Resource is used across multiple servers—synchronization cannot be guaranteed.


Example

 

In this example, we use a Web page that already includes the code for animations, we just trigger the function itself.

 

  1. First create a Web Browser Resources, assign the Page to load and put it in the Timeline.
     
  2. Create a NewModule and a New Action. Expanding Your ModulesExpanding Your Actions.
     
  3. Use the API call executeJavaScriptOnCurrentWebResource to trigger the in the HTML stored animation: 
    1. Pixera.Timelines.Layer.getInst('Timeline 1.Layer 1').executeJavaScriptOnCurrentWebResource("startAnim()")
  4. Create a Cue to trigger the Control Action Cue Network Command (pixc)
     

TIP

This can also be achieved using Keyfames on a Data Layer, which is often the preferred method.

Learn more in the article: From Timeline to Control.

 

 

Below is the PIXERA Show file with the HTML Test page for testing the functionality:


Use Cases

 

Reload

 

A common scenario is refreshing the browser window without unloading and re‑loading the entire container.

In plain JavaScript you can do this with: 

location.reload();

This refreshes the page exactly as if you had pressed F5 in your browser. This is handy when a Web Resource needs to update text or other dynamic values during playout, but you want to avoid a full container reset.


Button Press

 

With the functionality, it is possible to press buttons without the use of a mouse.

// If the button has an ID
document.getElementById('myButton').click();
// If the button has a class
document.querySelector('.myButton').click();

 

In the Example below, the Button has neither a class nor an id, but it can still be referenced:

local js_code = [[
    document.querySelector('button[onclick="startAnim()"]').click();
]]
Pixera.Timelines.Layer.getInst('Timeline 1.Layer 1').executeJavaScriptOnCurrentWebResource(js_code)

PIXERA 26.2 INTER 62 | 17 April 2026 | C.L.

Was this article helpful?