简体   繁体   English

在找到的页面上突出显示搜索词

[英]Highlight search terms on found page

I am using a Google Custom Search Engine ( link and API ) to provide a site search for my website. 我正在使用Google自定义搜索引擎( 链接API )为我的网站提供站点搜索。 For now I have a poorly styled <gcse:searchbox-only> on my main site; 现在,我的主站点上的<gcse:searchbox-only>样式不佳; this pops open the results. 这会打开结果。 (At some point I'd like to use the <gcse:searchresults-only> on a separate page. (有时,我想在单独的页面上使用<gcse:searchresults-only>

However, because some of the pages shown in the result list are rather lengthy, I wonder if there is a way to click on a search result link and highlight the matching text on the target page? 但是,由于结果列表中显示的某些页面很长,我想知道是否可以单击搜索结果链接并在目标页面上突出显示匹配的文本? I don't want to highlight the search terms on the result list, but rather on the target page a user selects from the Google result list. 我不想在结果列表上突出显示搜索词,而是在用户从Google结果列表中选择的目标页面上。

How would I go about this? 我将如何处理?

EDIT: Here is an example of what I mean. 编辑:这是我的意思的例子。 Use Google to search for "man strcpy" ( click ) and the first search result should be at linux.die.net. 使用Google搜索“ man strcpy”单击 ),第一个搜索结果应该在linux.die.net上。 When I click on that link, it'll take me to the website and highlight both "man" and "strcpy" on that target page. 当我单击该链接时,它将带我到网站,并在该目标页面上突出显示“ man”“ strcpy” Is works when using Google, Bing, Yahoo. 使用Google,Bing,Yahoo时可以使用。

From a quick scan of the docs I see that you can use either the data-queryParameterName or queryParameterName , with the value 'search' to pass the search term/phrase to your results page. 文档的快速扫描中,我看到您可以使用data-queryParameterName queryParameterName ,并将值'search'传递给搜索词/短语到您的结果页面。 You could then get the query string and pass it along. 然后,您可以获取查询字符串并将其传递。

Once the user clicks from the results list to the intended page, you'd have the query available and could highlight the results. 用户从结果列表中单击到所需页面后,您便可以使用该查询并突出显示结果。

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

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