jquery anchor to html extract
- by Benjamin Ortuzar
I would like to implement something similar to the Google quick scroll extension with jquery for the extracts of a search result, so when the full document is opened (within the same website) it gives the user the opportunity to go straight to the extract location.
Here is a sample of what I get returned from the search engine when I search for 'food'.
<doc>
<docid>129305</docid>
<title><span class='highlighted'>Food</span></title>
<summary>
<summarytext>Papers subject to Negative Resolution: 4 <span class='highlighted'>Food</span> <span class='highlighted'>Food</span> Irradiation (England) Regulations 2009 (S.I., 2009, No. 1584), dated 24 June 2009 (by Act), </summarytext>
</summary>
<paras>
<paraitemcount>2</paraitemcount>
<para>
<paraitem>1</paraitem>
<paraid>42</paraid>
<pararelevance>100</pararelevance>
<paraweights>50</paraweights>
<paratext>4 <span class='highlighted'>Food</span></paratext>
</para>
<para>
<paraitem>2</paraitem>
<paraid>54</paraid>
<pararelevance>100</pararelevance>
<paraweights>50</paraweights>
<paratext><span class='highlighted'>Food</span> Irradiation (England) Regulations 2009 (S.I., 2009, No. 1584), dated 24 June 2009 (by Act), with an Explanatory Memorandum and an Impact Assessment (</paratext>
</para>
</paras>
</doc>
As you see the search engine has returned a document that contains one summary and two extracts.
So let's say the user clicks on the second extract in the search resutls page, the browser would open the detailed document in the same website, and would offer the user the possibility to go to the extract as the Google quick scroll extension does.
Is there an existing jquery script for this? If not, can you suggest any jquery/javascript code that would simplify my task to implement this.
Notes:
I can access the extracts from the document details page.
I'm aware that the HTML in some cases could be slightly different in the extract than in the details page, finding no match.
The search engine does not return where the extract was located.
At the moment I'm trying to understand the JS code that the extension uses.