improving the "setfocus" JavaScript

HIP3 contains some JavaScript that sets the focus to the search box everytime a page is loaded – this means you can start typing text straight in to the box.
However, if you’ve already done a search, then it can be frustrating for the user to have the page suddenly jump to the top (especially if they are using the back button to return to a list of search results). In fact, it make more sense for the JavaScript to only set the focus on the initial search screens.
Here’s a quick hack that disables the JavaScript “setfocus” function for search result and full bib pages:
Open up searchresponse.xsl file and find the <body> tag (it’s around line 230)
A few lines down you’ll find the onload attribute code – this tells the web browser to execute the startTimer and setfocus JavaScript functions as soon as the page has loaded:

<xsl:attribute name="onload">startTimer();setfocus();</xsl:attribute>

Replace that entire line of code with the following:

<!-- disable the setfocus for search result pages -->
<xsl:if test="not(boolean(/searchresponse/yoursearch))">
<xsl:attribute name="onload">startTimer();setfocus();</xsl:attribute>
</xsl:if>
<xsl:if test="(boolean(/searchresponse/yoursearch))">
<xsl:attribute name="onload">startTimer();</xsl:attribute>
</xsl:if>
<!-- end of changes -->

Save the searchresponse.xsl file and check your HIP to see if the change works!
The usual notes apply:

  1. this worked fine for our UK HIP 3.04
  2. back up your original searchresponse.xsl file before you make any changes!
  3. if you’ve got one, try it on your test HIP server first

Remind users to Log Out

Just a quick addition to the toolbar2.xsl file to remind a logged in user to log out:

Open up toolbar2.xsl and search for the following comment:

<!-- Logout option -->

A couple of lines below that, insert the code shown in blue after the <td> tag:

<xsl:if test="$patron_empowerment_disable = $false">
<td>
<span style="color: red; border-bottom: dashed black 1px; font-size: x-small;
font-weight: bold;">Don't forget to logout when you have finished!</span>
<xsl:variable name="list"> . . . .

some notes:

  1. this worked for me with the UK HIP 3.04 release
  2. back up your original toolbar2.xsl file before you make any changes!
  3. if you’ve got one, try it on your test HIP server first!