Trigger a script when user is navigating to a page in a tab that's already opened

Hello,

I want to make a dynamic menu that shows recently visited pages. I want to update a FlexRepeater whenever the user navigates to a new page. I tried using Page StartUp session event. However, this will only work when the user refreshes a page or opens a page in a new tab or window. Is there a way to trigger scripts when the user i navigating between pages in a tab or window that is already opened?

I'm assuming they are navigating the pages via some sort of button.

Which could be where you place a script. When they click to navigate a page you add it to the list, And the list only stores x number of recent pages. of course, with a method of ordering tossed in.

That would be possible, but the tool we are developing have too many ways to navigate to different pages. It would be the most efficient if there was a way to develop a trigger that acts when the url changes. This could be done by a timer script and a while loop, but I am trying to avoid having while loops running constantly in the background

Maybe if I make memory tag that stores the current url and uses a gateway event on tag change to script it...

1 Like

however, I am not able to get the current URL

I'm not too familiar with perspective. But I don't think it's feasible to monitor the URL. in a tag.

Especially because you can open views without changing the URL just passing it as a keyword argument. And it might be hard to monitor what is open as you may not be closing them.

Also, a gateway script would be no good. It cannot know the URL of a client-side session.

Yeah I was just typing up that response.

You are gonna have to add something at each place you open a page from even if its a custom property you can change and monitor.

Someone may chime in on a better way

If you write it to a custom session property, you can trigger off that.

1 Like

Would he have to write it as each place he opens it? Or would he be able to write it via monitoring it someway more central?

He'd have to write it as he opens it. There's no way to directly access a view's URL because you could have multiple URLs to the same view. You can also navigate to views without changing the URL.

@JordanCClark thats what I thought. Aligns with my original suggestion, but he didn’t like it.

My only other thought to the OP would be to focus on templates and indirect addressing. Maybe he can condense the many ways they open into some sort of dynamic structure .

The only way to manage something like this requires a piece of UI shared across all pages in the project. We have something like this in our automated testing project, where there is a shared Docked View we use for navigation.

Within the View used for the Docked View, bind some custom property against page.props.path (ignore any preview in the Designer as the page path prop behaves differently in the Designer). Now, you just need to place a change script on this custom property and you'll know whenever any open page for the session changes the URL.