我可以使用以下代码来获取所选文本:
text=window.getSelection(); /// for Firefox
text=document.selection.createRange().text; /// for IE
但是如何获得所选的Html,其中包括text和html标签?
我有一个页面上有博客文章.人们可以选择本文的一部分,我想存储他们选择的部分,但不仅仅是屏幕上的文本,HTML源.
例如,屏幕显示;
Boerboel育种者协会于1983年在Senekal区成立.
完整代码是:
<p>
The Boerboel Breeders Association was <strong>established in 1983</strong> in the Senekal district.
</p>
Run Code Online (Sandbox Code Playgroud)
所以我希望当有人选择"1983年在Senekal区成立"时,它会返回给我的源代码如下:
was <strong>established in 1983</strong> in the Senekal district
Run Code Online (Sandbox Code Playgroud)
我正在使用Javascript和jQuery.
我需要从javaFX中的webView获取所选文本.我还没有找到任何线索如何在互联网上做到这一点.