Need help with Layout html in 2.42 webhelp skin

This is the place to share H&M templates and utilities with other users. Topic templates can be posted as text attachments (*.txt) or in the posting itself between [code] and [/code] tags. Print manual templates (*.mnl) are digital and can only be posted as attachments. Utilities and multiple files can be posted in ZIP archives. Please include plenty of comments so that users understand what you're doing! Registration is required to access this forum.

Moderators: Alexander Halser, Tim Green

Need help with Layout html in 2.42 webhelp skin

Unread postby Wayne Chen » Wed Oct 22, 2014 6:34 am

For various reasons related to the winbook format and CSH we are trying to change the "Previous" and "Next" arrow buttons to behave like the "Back" and "Forward" buttons on a browser.

Looking at the Layout HTML code, it appears this section sets the behavior of the "Previous" and "Next" icons.
Code: Select all
<div class="naviconboxR" title="Previous topic">
     <a id="navicon_previous" href="#" target="hmcontent" onclick="hmWebHelp.tocWin.tocScroller(this.href)"><img class="navicon" src="arrow_left.png" title="<%BTNTEXT_PREVTIP%>" alt="<%BTNTEXT_PREVTIP%>" /></a>
     <br /><span class="navtextOn"><%BTNTEXT_PREV%></span>
     </div>
     <div class="naviconboxR" >
     <a id="navicon_next" href="#" target="hmcontent" onclick="hmWebHelp.tocWin.tocScroller(this.href)"><img class="navicon" src="arrow_right.png" title="<%BTNTEXT_NEXTTIP%>" alt="<%BTNTEXT_NEXTTIP%>" /></a>
     <br /><span class="navtextOn"><%BTNTEXT_NEXT%></span>
     </div>


We've tried changing the "Previous" onclick code to

Code: Select all
onclick="window.history.back()"


And that seems to work well for going back to the topic you were on.
What we are having trouble with is with the "Forward" code.
we have tried:

Code: Select all
onclick="window.history.forward()"


But for some reason it does not work at all. It just goes to the next topic.

eg

3 topics:

Intro
Topic1
Topic2

Start on Intro, then click on Topic2.
Clicking the "Back" button should take it back to Intro (which it does), then clicking the "Forward" button should return it to Topic 2 (which is what the browser forward button does), but instead it takes it to Topic1.

Stumped :(
User avatar
Wayne Chen
 
Posts: 13
Joined: Mon Sep 08, 2014 2:23 am
Location: Sydney

Re: Need help with Layout html in 2.42 webhelp skin

Unread postby Tim Green » Wed Oct 22, 2014 9:35 am

Hi Wayne,

For various reasons related to the winbook format and CSH we are trying to change the "Previous" and "Next" arrow buttons to behave like the "Back" and "Forward" buttons on a browser.

The target topics for the links in those buttons are dynamically populated with the addresses of the next and previous topics for the current topic when a topic file is loaded -- the address is loaded into the href attribute of the link. The click handler is not loading the topic, it is only synchronizing the TOC highlight and scrolling the TOC into the correct position. Since the default click behavior of the <a> tag is to load the HTML file referenced in the href attribute, what is happening in your solution is that you are getting a conflict between the default click behavior and the history command you are executing. What you need to do is to suppress the default click behavior, like this:

Code: Select all
<a id="navicon_previous" href="#" target="hmcontent" onclick="event.preventDefault();window.history.back();">
...
<a id="navicon_next" href="#" target="hmcontent" onclick="event.preventDefault();window.history.forward();">

You should also change the BTNTEXT.. variables to provide meaningful tooltips and captions for the changed behavior. That will work, but the buttons won't provide any indication when the end and beginning of the current history stack are reached -- they just won't do anything when they are clicked when that happens.

Important note: If you link to the help with URLs that use just reference topic.htm instead of index.html?topic.htm the history buttons won't work correctly. That has nothing to do with the code in the buttons, it's just a function of how the history doesn't work for pages with files loaded into iFrames when they are accessed like that.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Tim Green
Site Admin
 
Posts: 21041
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany

Re: Need help with Layout html in 2.42 webhelp skin

Unread postby Wayne Chen » Wed Oct 22, 2014 10:08 pm

Hi Tim,

Thanks for the quick reply! The suggested code works great.

Keep up the great work :)

Cheers,

Wayne
User avatar
Wayne Chen
 
Posts: 13
Joined: Mon Sep 08, 2014 2:23 am
Location: Sydney


Return to Templates & Utilities

Who is online

Users browsing this forum: No registered users and 1 guest

cron