# \[IGN-9270\] Scroll scrollbar to position via script - Perspective?

**URL:** <https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584>\
**Category:** Ignition\
**Tags:** ignition81, perspective, vision\
**Created:** [February 12, 2024, 7:49pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584 "2024-02-12T19:49:30Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![OmronOmicronII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/omronomicronii/32/58016_2.png) [@OmronOmicronII](https://forum.inductiveautomation.com/u/OmronOmicronII)\
**Post date:** [February 15, 2024, 1:37pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/22 "2024-02-15T13:37:23Z")

</div>

Still brings me to the top of the page using:

```auto
system.perspective.navigate(url="/data/perspective/client/Machine_Data_View/master-view#navBack")

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 15, 2024, 3:04pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/23 "2024-02-15T15:04:21Z")

</div>

Ah, I missed that you're not supplying the Gateway address. You need to treat this as a full URL. It might work if you change the navigation strategy from URL to page... But I'm confident in the URL approach.

---

<div class="post-metadata">

**Author:** ![OmronOmicronII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/omronomicronii/32/58016_2.png) [@OmronOmicronII](https://forum.inductiveautomation.com/u/OmronOmicronII)\
**Post date:** [February 15, 2024, 3:08pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/24 "2024-02-15T15:08:25Z")

</div>

Did this with same result

```auto
system.perspective.navigate(url="http://<gateway IP>:<port>/data/perspective/client/Machine_Data_View/master-view#navBack")

```

I appreciate your help btw

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 15, 2024, 3:13pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/25 "2024-02-15T15:13:23Z")

</div>

You should use the inspector tool on your browser to verify that the target component in the DOM actually has your expected ID. (And that they are all unique. If duplicate, I believe you will simply get the first one.)

---

<div class="post-metadata">

**Author:** ![OmronOmicronII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/omronomicronii/32/58016_2.png) [@OmronOmicronII](https://forum.inductiveautomation.com/u/OmronOmicronII)\
**Post date:** [February 15, 2024, 3:20pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/26 "2024-02-15T15:20:41Z")

</div>

looks like it did not take my "navBack" name.

```auto
<div id="coordinateGhost" style="width: 1595.14px; height: 573.04px; z-index: -200000;"></div>

```

I also tried "coordinateGhost" in my URL and it still brought me to the top of the page.

Edit: I also found this

 while inspecting another component. Seems to be it but i'll have to dig through the layers and see how to call "navBack"  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/d/bdfcecc3216f9db0f8547ddf68cd3346ad49e180.png)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 15, 2024, 3:26pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/27 "2024-02-15T15:26:35Z")

</div>

What is the URL you have configured for this page with your Page Configuration?

---

<div class="post-metadata">

**Author:** ![OmronOmicronII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/omronomicronii/32/58016_2.png) [@OmronOmicronII](https://forum.inductiveautomation.com/u/OmronOmicronII)\
**Post date:** [February 15, 2024, 3:37pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/28 "2024-02-15T15:37:29Z")

</div>

This is the main page where I have my embedded view domId configured as "navBack"

```auto
http://<gatewayIP>:<port>/data/perspective/client/Machine_Data_View/master-view

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 15, 2024, 4:22pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/29 "2024-02-15T16:22:29Z")

</div>

And `master-view` is the Primary View configured for that Page Configuration? That's not the name of the Embedded View, is it? I guess what I'm asking is: could you provide a screenshot of the Page Configuration?

---

<div class="post-metadata">

**Author:** ![OmronOmicronII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/omronomicronii/32/58016_2.png) [@OmronOmicronII](https://forum.inductiveautomation.com/u/OmronOmicronII)\
**Post date:** [February 15, 2024, 8:44pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/30 "2024-02-15T20:44:45Z")

</div>

master-view is a flex container with embedded views within it:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cf52036dcf1e7e6d891d105670709e7476d922ee.png)

master-view url:

```auto
http://<gatewayIP>:<port>/data/perspective/client/Machine_Data_View/master-view

```

I added the domID to the IJ\_EmbeddedView:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/c/1cc8892e34f33dddc36ecb0a0e8c35c03cea1d1c.png)

on a different page I have the back button with the onClick event configured as a python script system function:

```auto
system.perspective.navigate(url="http://<gatewayIP>:<port>/data/perspective/client/Machine_Data_View/master-view#navBack")

```

Let me know if you need more info

---

<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:** [February 15, 2024, 9:05pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/31 "2024-02-15T21:05:56Z")

</div>

As far as I know, domID goes into META, not PROPS.

![domId](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/3/e322baa23f3f134b068846508cddf73d693b37c2.png)

---

<div class="post-metadata">

**Author:** ![OmronOmicronII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/omronomicronii/32/58016_2.png) [@OmronOmicronII](https://forum.inductiveautomation.com/u/OmronOmicronII)\
**Post date:** [February 15, 2024, 9:10pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/32 "2024-02-15T21:10:22Z")

</div>

Didn't provide the whole pic

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/d/bd40c446a28144515f085022ebd5c342d215e724.png)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 15, 2024, 10:32pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/33 "2024-02-15T22:32:26Z")

</div>

Hmmm. After looking at this a bit closer, it seems my usages have all been piggy-backing on browser behavior, and that my suggested approach only works when that sort of navigation occurs while you're already on the page which has the scroll target.

In theory you could put this behavior into place yourself, but it's going to be a bit more complicated.

Whichever Embedded View is navigating to a new page will need to pass along the target `domId` value, just like before. Instead of performing URL navigation, you must do `page` navigation and pass along the target value as a param.

The MasterView View will need to add a case-sensitive param key at the View node level (not the `root` node) with an empty string as the default value. You'll place a change script on this param property which then again performs navigation while targeting the value.

Flow:

1. MasterView has a `param` with a name of `scrollTarget`, which has a default value of an empty string.
2. `MasterView.params.scrollTarget` has a change script which uses the `url` navigation approach -\>

```auto
if currentValue.value: # sneaky check to avoid any action when the value is an empty string
    system.perspective.navigate(url="http://<gatewayIP>:<port>/data/perspective/client/Machine_Data_View/master-view#{0}".format(currentValue.value))

```

1. MasterView Embedded View is clicked.
2. This performs `page` navigation and passes along the `domId` value of the Embedded View as a param.
3. On this second page, some sort of UI is used for getting back to the first page by performing `page` navigation (not `url`), and passes the received param back as `scrollTarget`.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 15, 2024, 10:57pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/34 "2024-02-15T22:57:33Z")

</div>

I've opened an internal ticket to get this working during navigation because I would have expected that to work. We shouldn't require you already be on the page with the target.

---

<div class="post-metadata">

**Author:** ![OmronOmicronII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/omronomicronii/32/58016_2.png) [@OmronOmicronII](https://forum.inductiveautomation.com/u/OmronOmicronII)\
**Post date:** [February 16, 2024, 7:41pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/35 "2024-02-16T19:41:02Z")

</div>

Yeah I tried using a sendMessage from a different view that had a payload of "navBack". I was able to send it over to the master-view and see the results on a test label, but it did not initiate a change script on the scrollTarget param since I was on a different page. So then I used the same sendMessage function on a button inside the master-view, and it brought me to the proper embedded view scroll location.

```auto
	messageType = 'scrollTarget'
	value = "navBack"
	payload = {'key':value}
	
	system.perspective.sendMessage(messageType, payload, scope = 'session' )

```

```auto
def onMessageReceived(self, payload):
	#for testing
	self.getSibling("testLabel").props.text = payload['key']
	#move "navBack" from other view into scrollTarget on master-view param
	self.view.params.scrollTarget = payload['key']

```

```auto
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if currentValue.value: # sneaky check to avoid any action when the value is an empty string
		system.perspective.navigate(url="http://<gatewayIP>:<port>/data/perspective/client/Machine_Data_View/master-view#{0}".format(currentValue.value))

```

Seems like I was unsuccessful in finding a method to do it from another page.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 16, 2024, 8:21pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/36 "2024-02-16T20:21:06Z")

</div>

No, don't send a message, navigate with params.

```auto
    system.perspective.navigate(url="http://<gatewayIP>:<port>/data/perspective/client/Machine_Data_View/master-view/{0}".format(self.params.scrollTarget))

```

Your Page Configuration will need to be updated to receive this param:

```auto
# new url
/master-view/:scrollTarget

```

---

<div class="post-metadata">

**Author:** ![OmronOmicronII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/omronomicronii/32/58016_2.png) [@OmronOmicronII](https://forum.inductiveautomation.com/u/OmronOmicronII)\
**Post date:** [February 26, 2024, 6:59pm UTC](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584/37 "2024-02-26T18:59:09Z")

</div>

Yeah tried that and then moved on to messages. Using params, I can only get it to work when I am on the same page. If I send a new url param from a different page, the master-view receives the new url param but does not run the change script.

[Previous page](https://forum.inductiveautomation.com/t/ign-9270-scroll-scrollbar-to-position-via-script-perspective/85584.md?page=1)
