简体   繁体   English

锚标记href和onclick

[英]Anchor tag href and onclick

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. 我对JavaScript非常陌生,并且在HTML帮助研讨会中使用JavaScript来生成chm格式的已编译帮助文件。在这里,我需要定位标记来链接一个html页面并突出显示该页面中用户搜索到的单词。

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. 因此,anchor标签必须同时具有href (对于链接作为变量)和onclick (对于突出显示单词)功能。(首先执行href然后第二次执行onclick函数)。我尝试了很多,但都失败了。

help me to solve this problem and please use the following innerHTML way... 帮助我解决此问题,请使用以下innerHTML方式...

<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. 这可能是与常规HTML锚链接结合使用的解决方案。 A German CHM viewer window has a tab Suchen (Search) on the left side navigation pane. 德语CHM查看器窗口的左侧导航窗格上具有Suchen (搜索)选项卡。

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. 在“帮助”主题中搜索单词时,您可以指定在找到的主题中突出显示每次搜索的单词或短语。

  • On the Viewer toolbar, click View and then click Highlights to add a checkmark to this option to highlight all instances of the word or 在查看器工具栏上,单击“查看”,然后单击“突出显示”以向该选项添加一个选中标记以突出显示该单词或
    phrase. 短语。
  • On the Viewer toolbar, click View and then click Highlights to remove the checkmark from this option and to turn off this 在查看器工具栏上,单击“查看”,然后单击“突出显示”以从此选项中删除选中标记并关闭此选项。
    feature. 特征。

For special case (see snapshots) there are some methods using JavaScript. 对于特殊情况(请参见快照),有一些使用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. 您可以从以下网址下载示例文件: http : //www.help-info.de/files_download/CHM-example_project.zip请注意:要打开此ZIP / CHM文件,请右键单击已保存的文件(解压缩前为ZIP),然后单击单击属性,然后单击取消阻止。

For some further search information please have a look at: http://www.help-info.de/en/Help_Info_HTMLHelp/hh_fts.htm 有关更多搜索信息,请访问: http : //www.help-info.de/zh/Help_Info_HTMLHelp/hh_fts.htm

在此处输入图片说明在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM