Add some more Javascript to your Catalogue

A little while ago I posted an entry about adding some JavaScript to your catalogue, adding a link when your title search fails. Well here is the other part, adding a link when your keyword search fails.
If you run an Inn-Reach system then you may want something more then the simple Inn-Reach button, like say some words that say what your actually doing if you click this button. The problem is III only gives you an Inn-Reach token and if you try to surround that with a div or type something in front of the token, it works but it stays there all the time which we don't want. So in order to get your phrase to appear only when a keyword search fails simply add this to your srchelp Y page:

SCRIPT LANGUAGE="Javascript1.2"
function LIWA() {
var srch = 'a class="mine" href="http://liwa.ac.ae/search/Y' + location.search + '"> img src="/screens/LiwaLogo.jpg" border="0"//a';
document.writeln('Not finding what you want at HCT? Try searching the LIWA Catalogue:');
document.writeln(srch);
}

if (document.getElementById) {
var x=document.getElementById("msg");
var txt = x.innerHTML;
if (txt.indexOf("NO ENTRIES FOUND") != -1) {
LIWA();
}
}
/SCRIPT

That should be everything you need to make it work. You can check out how it works in our library catalogue. Feel free to change anything that you want, I'm sure this could be more robust but we simply needed something to let people know that hey you search failed want to look in Inn-Reach?

0 comments: