# Onload scripting for each window

**URL:** <https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065>\
**Category:** Ignition\
**Created:** [February 24, 2012, 8:42pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065 "2012-02-24T20:42:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecujak](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@ecujak](https://forum.inductiveautomation.com/u/ecujak)\
**Post date:** [February 24, 2012, 8:42pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/1 "2012-02-24T20:42:07Z")

</div>

How do I run scripts when a window loads? Is there an “onload” event?

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [February 24, 2012, 9:44pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/2 "2012-02-24T21:44:53Z")

</div>

Right click on the Window in the Project Browser, then click “Event Handlers”. Select one of the following to place your code. I recommend trying out internalFrameActivated first.

• internalFrameActivated - fired when the window becomes the focused window  
• internalFrameClosed - fired after the window is closed  
• internalFrameClosing - fired just before the window is closed  
• internalFrameDeactivated - fired when the window loses focus  
• internalFrameOpened - fired the first time a window is opened after not being in the cache

---

<div class="post-metadata">

**Author:** ![ecujak](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@ecujak](https://forum.inductiveautomation.com/u/ecujak)\
**Post date:** [February 27, 2012, 4:26pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/3 "2012-02-27T16:26:32Z")

</div>

Very nice, thank you. If this is in the manual, I am sorry I missed it.

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [February 27, 2012, 9:33pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/4 "2012-02-27T21:33:46Z")

</div>

No problem - that one wasn’t obvious to find in the manual.

[inductiveautomation.com/support/ … \_types.htm](http://inductiveautomation.com/support/usermanuals/ignition/event_types.htm)

---

<div class="post-metadata">

**Author:** ![markdobtech](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@markdobtech](https://forum.inductiveautomation.com/u/markdobtech)\
**Post date:** [March 6, 2012, 2:45pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/5 "2012-03-06T14:45:20Z")

</div>

Be careful with internalFrameActivated. If you have more than one window opened and change focus from one to the other, the window with the internalFrameActivated event script will fire when it regains focus, causing any script within the event to run (as opposed to only on open).

Using internalFrameOpened can also present a coding issue in that the event will fire the fist time the windows is opened and inserted into the cache. Closing the window does not necessarily remove it from the cache and subsequent opening of the window will not fire the event.

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [March 6, 2012, 3:06pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/6 "2012-03-06T15:06:22Z")

</div>

Mark - correct. You can change the cache policy of the window.

The [manual page on Window properties](http://inductiveautomation.com/support/usermanuals/ignition/window_properties.htm) covers your caching options.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 8, 2012, 7:04pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/7 "2012-05-08T19:04:35Z")

</div>

In Ignition 7.5 there will be windowOpened and windowClosed events that will avoid then confusion of the internal frame events

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [May 8, 2012, 7:13pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/8 "2012-05-08T19:13:44Z")

</div>

Will there also be a windowFocus event?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 14, 2012, 10:02pm UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/9 "2012-05-14T22:02:22Z")

</div>

No, that’s exactly how internalFrameActivated behaves

---

<div class="post-metadata">

**Author:** ![Behzad.Ebrahimi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/behzad.ebrahimi/32/38108_2.png) [@Behzad.Ebrahimi](https://forum.inductiveautomation.com/u/Behzad.Ebrahimi)\
**Post date:** [August 20, 2022, 12:01am UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/10 "2022-08-20T00:01:32Z")

</div>

Is there any updated answer in 2022?  
I use Ignition 8.1.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [August 20, 2022, 12:08am UTC](https://forum.inductiveautomation.com/t/onload-scripting-for-each-window/4065/11 "2022-08-20T00:08:00Z")

</div>

Vision window opened:  
[https://docs.inductiveautomation.com/display/DOC81/Component+Events#ComponentEvents-VisionWindowEventHandlers](https://docs.inductiveautomation.com/display/DOC81/Component+Events#ComponentEvents-VisionWindowEventHandlers)  
Perspective page startup:  
[https://docs.inductiveautomation.com/display/DOC81/Perspective+Session+Event+Scripts#PerspectiveSessionEventScripts-PageStartup](https://docs.inductiveautomation.com/display/DOC81/Perspective+Session+Event+Scripts#PerspectiveSessionEventScripts-PageStartup)  
Perspective view/component startup:  
[https://docs.inductiveautomation.com/display/DOC81/Perspective+Event+Types+Reference#PerspectiveEventTypesReference-SystemEvents](https://docs.inductiveautomation.com/display/DOC81/Perspective+Event+Types+Reference#PerspectiveEventTypesReference-SystemEvents)
