Reputation: 126
I'm trying to highlight the selected text contents by the user inside the HTML page I loaded using PHP + XSL transformation. I have seen some solutions related with highlighting current selected text, but I need to save some information to the database that makes me able to highlight the same contents for future loads of the same page, taking care of all inner elements that the text could have inside.
The idea is simple: simulate when you use a marker inside a book.
Any ideas? Any suggestion will be appreciated.
Thank you in advance.
Isaac
Upvotes: 4
Views: 2271
Reputation: 971
This feature might help you.
just add #:~:text=Highlight%20These
try accessing this link for demo
https://stackoverflow.com/questions/38588721#:~:text=Highlight%20a%20text
Upvotes: 0
Reputation: 18968
Use AJAX.
http://www.w3schools.com/Ajax/Default.Asp
IMO, DOM location and the STRING range.
something like,
DOM_LOCATION: div[0]>p[2]>span[1]
STRING_RANGE: 2:20
this means that the string user highlighted from the 2nd character to the 20th character of the 2nd span of the 3rd paragraph of the 1st div, which is "monstration of some" from the example below.
<div>
<p>This has no use.</p>
<p><em>And so is</em> this one.</p>
<p><span>This</span> is the <span>demonstration of something wonderful</span>.</p>
</div>
All you need to do is reverse the DOM location and use the range.
Upvotes: 0