-1

I need to create a button in the TwinCAT HMI 3 toolbar that, when clicked, will take me to the top or bottom of the current content, such as Page1, without having to scroll. Does anyone have any ideas?

I used several factions but it didn't work. I don't know what function is supported in TwinCAT3 HMI software.

Majid
  • 1
  • 2
  • Question is unclear and please add more details. – Xab Ion Aug 26 '23 at 13:54
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 26 '23 at 13:54
  • My need: By using the Event tab of a button and through JavaScript in the TwinCAT HMI environment, I can go to the beginning of the page I am on by clicking on that button. Actually: scrollTop – Majid Aug 27 '23 at 04:46
  • Example: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_scroll_to_top – Majid Aug 27 '23 at 05:52
  • Now suppose I want to jump to the bottom of the page or go to a desired point, what code should I use? – Majid Aug 28 '23 at 12:49

2 Answers2

0

Place a button in the graphic environment of TwinCAT HMI software, and then click on the OnPressed option in its Event tab and put the following Java code in it. Now, if you put the name of the page you are on and expect to jump to the top of that page instead of the phrase Page1, your code will work correctly.

document.getElementById("Page1").scrollIntoView();
DarkBee
  • 16,592
  • 6
  • 46
  • 58
Majid
  • 1
  • 2
  • But I still haven't found a way to give a specific position. I mean, for example, I can scroll at position (0,500). – Majid Aug 29 '23 at 08:14
  • The following command does not work in the TwinCAT HMI software environment. Can anyone help me? element.scrollTo(0, 1000); – Majid Aug 29 '23 at 08:25
0

To scroll to the bottom of the page, you need to use the following code

document.getElementById("Page1").scrollIntoView(false);

Majid
  • 1
  • 2