Go to Top button

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
Ruwin
Propeller Head
Posts: 12
Joined: Wed Dec 14, 2011 4:18 am

Go to Top button

Post by Ruwin »

Hello,

I've been trying to create button (Toolbar button for HTML5) that will scroll to the top of the page when pressed. It is very useful to me since we have long articles in our knowledge base. I have tried the Javascript way, with window.scrollTo(0,0) but no effect. I think because the actual page is not scrolling.

Do you have any idea on how to create this functionality?
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Go to Top button

Post by NorthEast »

Using window.scrollTo(0,0); will scroll the current page, so it will work if it's in the body of the topic itself; e.g.

Code: Select all

<a href="#" onclick="javascript:window.scrollTo(0,0);">Go to top</a>
However, the toolbar is not part of the topic page in either WebHelp or HTML5 help, it is in a separate page which is inside an iframe/frame. So that script won't work since it will try to scroll the page that contains the toolbar, not the page containing the topic.

To get this to work in a toolbar button, you need to tell it to scroll the page iframe/frame that contains the topic.

For HTML5, you need to scroll the 'topic' iframe:

Code: Select all

window.top.topic.scrollTo(0,0);
For WebHelp you need to scroll the 'body' frame:

Code: Select all

window.top.body.scrollTo(0,0);
Ruwin
Propeller Head
Posts: 12
Joined: Wed Dec 14, 2011 4:18 am

Re: Go to Top button

Post by Ruwin »

Thank you very much! I totally forgot about the topic iframe. :)
Post Reply