I have an object embed html element that is used to display a webpage selected by the user.
The embed declaration is quite simple:
<embed id='frame' src=file></embed>
Where file is a url formatted in this way: "http:// www. something .bla" ; the element is created when the user enters a link in a search box and chooses to load it.
What I have to do is:
- assuming that the embed contains something (which means that the user has loaded a link),
- detect if the user has selected some text inside it (as an example, if the embed was showing this same page, and the user decides to select (highlight) the question title + the first row of the question, I should detect it),
- get the selection (html included) (so, in this example,
How do I get the selected text inside an object embed using jquery?
I have an object embed html element that is used to display a webpage selected by the user.
including the html tags,
- and then store it somewhere for further uses.
It may be done in whatever scripting language, it doesn't matter, but Javascript or jQuery would be better.
What I tried for the moment, using jQuery or Javascript:
- binding the getSelection() methods to the embed object (the embed id is "frame" in this case) like this:
document.getElementById('frame').getSelection()
- or like this:
$('frame').getSelection()
- or this:
$('frame').on("select", function() {
some code to perform action
});
But it doesn't work.
Any help is very appreciated :)