Page 1 of 1

Webhelp classic auto open first result on right pane

Posted: Tue Jan 16, 2018 9:02 pm
by pmorddlo
Hi, I have a requirement to output Webhelp that allows the opening of the first result in the right pane of Webhelp classic.

For instance, we have an application that will invoke Webhelp with the searchQuery parameter ie /webhelp/index.html?searchQuery=print. We want the first result found in the searchresults to be displayed in the right pane.

I thought I could use webhelp.head.script and supply some jquery to do this. However, the search results don't seem to be loaded until after my code has already run. That even if I use the jquery $( document ).ready function. I've also tried attaching my code to webhelp.body.script

My code is very simple. I get the link associated with the first result, and then use it to change the iframe (#frm) on the right.

Code: Select all

$( document ).ready(function() {
s = $('#foundLink0');
href = $(s).attr('href')
var $iframe = $('#frm');
$iframe.attr('src', href );
})
I don't see any other hooks that I could use to do this? Any suggestions?

Re: Webhelp classic auto open first result on right pane

Posted: Fri Jan 19, 2018 4:45 pm
by bogdan_cercelaru
Hello,

Instead of getting the @href value of the first link and then use it to change the iframe on the right, you could try to get the first link and then trigger a click event as it would be clicked by the user. I've tested using the webhelp.body.script parameter and the following code and it works:

Code: Select all


$(document).ready(function () {
$("#searchResults").on("DOMSubtreeModified", function () {
try {
var s = $('#foundLink0');
s.click();
} catch (e) {

}
})
})
Regards,
Bogdan