Webhelp classic auto open first result on right pane

Post here questions and problems related to editing and publishing DITA content.
pmorddlo
Posts: 1
Joined: Tue Jan 16, 2018 5:29 pm

Webhelp classic auto open first result on right pane

Post 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?
bogdan_cercelaru
Posts: 222
Joined: Tue Jul 01, 2014 11:48 am

Re: Webhelp classic auto open first result on right pane

Post 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
Bogdan Cercelaru
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply