I am very new to JavaScript and i am using JavaScript in HTML help workshop to produce compiled help files in chm format.here i need anchor tag to link one html page and also to highlight the user searched word in that page.
So, anchor tag has to do both href (for link as a variable) and onclick (for highlight word) functionalities.(execute href first then onclick function as second).i tried a lot.but all are failure.
help me to solve this problem and please use the following innerHTML way...
<script>
..........
..........
frameDoc.body.innerHTML='<div><br><ul>';
for( l = 0; l < k; l++ )
{
var tmp1=searched_headings_filename[l];
var tmp2=searched_headings[l];
frameDoc.body.innerHTML+='<div style="margin-left:10;"><li class="highlight"><a href="'+tmp1+'" onclick="highlightSearch();">'+searched_headings[l]+'</a></li></div>';
}
frameDoc.body.innerHTML+='</ul></div>';
..........
..........
</script>
<script>
function highlightSearch()
{
alert('Successfully highlighted');
}
</script>
I'm not quit sure but it seems to me there is another way to solve the problem you described. So, I'll post some hints to highlight words in searched topics. This may be a solution for you combined with a normal HTML anchor link. A German CHM viewer window has a tab Suchen (Search) on the left side navigation pane.
When searching for words in Help topics, you can specify that each occurrence of the word or phrase you searched for is highlighted in the topics that are found.
For special case (see snapshots) there are some methods using JavaScript. You may download the sample files from: http://www.help-info.de/files_download/CHM-example_project.zip Please note: To open this ZIP / CHM file right-click the saved file (ZIP before extracting) , click Properties, and then click Unblock.
For some further search information please have a look at: http://www.help-info.de/en/Help_Info_HTMLHelp/hh_fts.htm
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.