This lesson is part of the Scripting in Ignition course. You can browse the rest of the lessons below.


Autoplay Off

Supplemental Videos


Page Startup


The Page Startup Session event triggers every time a new page is started in a Session. It's ideal if you want a script to execute whenever a new tab is open in a Session.

Video recorded using: Ignition 8.1


(open in window)

[00:00] In this video, we are going to go over the new perspective session event called page startup. It is located in the session events of perspective page startup. This particular script is fired whenever a new page is opened up in your web browser, either in a new tab or a new window. It can also be fired when a current page is refreshed by reloading the window in your browser. It will not run when navigating to different pages within the same tab. However, it will not run when navigating to different pages within the same window or tab. The event has a couple of arguments available to us. You'll notice we have a page object, as well as page ID and path properties. I have used these properties to create a very simple script, which simply prints them out to the console. It is important to note that to access the properties of the page object, you must use the props keyword first. So page.props.path to access that path property. I have also put together a simple set of views. Two of them are being used for two different pages and simply say this is page one, and this is page two. My third view is being used as a docked view and will provide some ways to navigate. Let's go ahead and launch my session. If I open the console by hitting the F12 key, you can see that my print did work on startup, giving me the page ID of this tab, as well as the path of the current page. If you use the navigation links on the left-hand side here it will actually open up a new tab. And if I again open up my console, I can see that again, my script ran. You will notice that while my page path is the same between the two tabs, my page ID is different, signifying that this is a new page that I have created. This will work regardless of which page I open to. The page path is now my new path, but the page ID is also different from the other pages that I've opened. Lastly, it is important to remember that navigating between pages within the same tab or window will not trigger this script to run. For example, if I switch over to page one within this same tab, you'll notice my script does not run again, regardless of which page I navigate to. I can, however, force the script to run by reloading the page. Now I have a new page path, because I am on page one, but my page ID is the same as it was before.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.