开发者

How to highlight an HTML content and save it to the database for future loads

I'm trying to highlight the selected text contents by the开发者_如何学JAVA 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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜