# Ignition Perspective - run script on page refresh

**URL:** <https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237>\
**Category:** Ignition\
**Created:** [August 7, 2019, 3:44pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237 "2019-08-07T15:44:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![David.Bell](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@David.Bell](https://forum.inductiveautomation.com/u/David.Bell)\
**Post date:** [August 7, 2019, 3:44pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/1 "2019-08-07T15:44:29Z")

</div>

Where can I put code to clear text fields when user refreshes page?

Thanks.

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [August 7, 2019, 3:51pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/2 "2019-08-07T15:51:31Z")

</div>

You can use the `onStartup` event on the view components.

---

<div class="post-metadata">

**Author:** ![David.Bell](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@David.Bell](https://forum.inductiveautomation.com/u/David.Bell)\
**Post date:** [August 7, 2019, 8:26pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/3 "2019-08-07T20:26:00Z")

</div>

I have tried several iterations and it does not handle it. I have a Main Menu View page that it defaults to on a refresh and when the user clicks the button to navigate to the next View, it does not actuate the “onStartup” code. If I start the webpage new, it works correctly, but does not act the same on page refresh.

---

<div class="post-metadata">

**Author:** ![anthony.kriz](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@anthony.kriz](https://forum.inductiveautomation.com/u/anthony.kriz)\
**Post date:** [June 2, 2020, 9:19am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/4 "2020-06-02T09:19:22Z")

</div>

Hello, Do you have find a solution for this ?  
Thanks

---

<div class="post-metadata">

**Author:** ![victor1](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@victor1](https://forum.inductiveautomation.com/u/victor1)\
**Post date:** [June 5, 2020, 11:24am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/5 "2020-06-05T11:24:45Z")

</div>

Hello, Do you have find a solution for this ?  
Thanks

---

<div class="post-metadata">

**Author:** ![Abhishek\_Kumar\_Tiwar](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@Abhishek\_Kumar\_Tiwar](https://forum.inductiveautomation.com/u/Abhishek_Kumar_Tiwar)\
**Post date:** [January 16, 2024, 10:49am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/7 "2024-01-16T10:49:54Z")

</div>

Hey David/anthony/victor,

Did you get any solution related to refresh button?

Thank you

---

<div class="post-metadata">

**Author:** ![Maxwell\_Wang](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Maxwell\_Wang](https://forum.inductiveautomation.com/u/Maxwell_Wang)\
**Post date:** [April 29, 2024, 10:39pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/8 "2024-04-29T22:39:05Z")

</div>

Hey David/Anthony/Victor/Abhishek,

Did you find any solution or workaround to this?

Thanks

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 11:11pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/9 "2024-04-29T23:11:02Z")

</div>

~~When the page is refreshed the components are restarted.~~

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [April 30, 2024, 12:17am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/10 "2024-04-30T00:17:01Z")

</div>

I don't think that is accurate. Those events don't fire on refresh. Please correct me if I'm wrong.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 30, 2024, 2:57am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/11 "2024-04-30T02:57:12Z")

</div>

You're right! My testing was incomplete.  
Thanks.

---

<div class="post-metadata">

**Author:** ![calimero100582](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/calimero100582/32/18630_2.png) [@calimero100582](https://forum.inductiveautomation.com/u/calimero100582)\
**Post date:** [April 30, 2024, 3:24am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/12 "2024-04-30T03:24:06Z")

</div>

Is there anyone with more details on this issue, because when I create a text field (without any binding), I input text in it, I refresh, and I no longer have a value.

If I use a binding with a local custom property, I still don't have any issues.

Issues appear when using session properties, and in our case, we try to avoid those as much as possible

---

<div class="post-metadata">

**Author:** ![Maxwell\_Wang](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Maxwell\_Wang](https://forum.inductiveautomation.com/u/Maxwell_Wang)\
**Post date:** [April 30, 2024, 3:16pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/14 "2024-04-30T15:16:00Z")

</div>

Components refresh their values / bindings when you refresh the page. But in my case, I would like to run a script when users refresh the page. There is no such event available, and the "on startup" event is triggered only once when the session starts. This issue has been brought up multiple times but the developer chose not to implement a solution because of the complexity involved in handling browser connections. So I am looking for a feasible workaround for this.

---

<div class="post-metadata">

**Author:** ![calimero100582](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/calimero100582/32/18630_2.png) [@calimero100582](https://forum.inductiveautomation.com/u/calimero100582)\
**Post date:** [April 30, 2024, 4:53pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/15 "2024-04-30T16:53:38Z")

</div>

so you said "Component refresh their binding on refresh", so you can just have a expression binding with now(0), add a script as a transform, and do whatever you want in it right?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [April 30, 2024, 5:03pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/16 "2024-04-30T17:03:49Z")

</div>

I don't think components refresh either. Drop a label with expression `now(0)` on the text prop. The time doesn't update when you hit refresh.

---

<div class="post-metadata">

**Author:** ![Maxwell\_Wang](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Maxwell\_Wang](https://forum.inductiveautomation.com/u/Maxwell_Wang)\
**Post date:** [April 30, 2024, 8:37pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/17 "2024-04-30T20:37:20Z")

</div>

After testing it out and as @jlandwerlen said, I might be wrong, components don't refresh their bindings

---

<div class="post-metadata">

**Author:** ![calimero100582](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/calimero100582/32/18630_2.png) [@calimero100582](https://forum.inductiveautomation.com/u/calimero100582)\
**Post date:** [April 30, 2024, 11:00pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/18 "2024-04-30T23:00:15Z")

</div>

do you disable persistent property?

> **[Perspective Component Properties | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/working-with-perspective-components/perspective-component-properties#persistent-properties)**
>
> Each Perspective component has a unique set of properties that can be set and modified within the Perspective Property Editor. A component property is simply a named variable with a distinct type that affects something about the component's behavior...

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 1, 2024, 12:48am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/19 "2024-05-01T00:48:24Z")

</div>

> Do you disable persistent property?

`Persistent = false` doesn't work either. Did you try it?

---

<div class="post-metadata">

**Author:** ![calimero100582](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/calimero100582/32/18630_2.png) [@calimero100582](https://forum.inductiveautomation.com/u/calimero100582)\
**Post date:** [May 1, 2024, 12:54am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/20 "2024-05-01T00:54:22Z")

</div>

Initial question was to find a way to clear text field, which I can't reproduce as when I refresh, text field are cleared, and people are asking if OP found a solution to his problem.

This is why I asked a bit more details on the goal people want to achieve.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 1, 2024, 1:04am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/21 "2024-05-01T01:04:52Z")

</div>

I have a view with two Text Field components on it (and a label).

- In Designer one is blank and one has some text.
- On both, `props.text` has Persistent = false.
- When the page first loads both are empty.
- If I type text into both, shift the focus onto a label (or press Enter to commit) and then refresh the page the text that I've just entered reappears.

Can you post the JSON of a Text Field component that clears when the page is refreshed in the browser?

---

<div class="post-metadata">

**Author:** ![calimero100582](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/calimero100582/32/18630_2.png) [@calimero100582](https://forum.inductiveautomation.com/u/calimero100582)\
**Post date:** [May 1, 2024, 3:11am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-run-script-on-page-refresh/27237/22 "2024-05-01T03:11:42Z")

</div>

with this case, I got couple issue, but using session event, on page startup, you will have a script that run on refresh, but not 100% certain you will be able to do what you want

> **[Perspective Session Event Scripts | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/scripting-in-perspective/perspective-session-events-scripts#page-startup)**
>
> Perspective offers a collection of Session Events designed to allow the Gateway to track and interact with the Session at critical moments. Specifically, they are scripts that run in the Gateway when a Session starts up, shuts down, or runs a...
