function sel_text()
{
var selectedHTML = document.selection.createRange().htmlText;
alert(document.selection.createRange().selectionstart);
var allHTML = document.all.FirstCol.innerHTML;
var LinksZahl = allHTML.indexOf(selectedHTML, document.selstart);
var Links = allHTML.substr(0,LinksZahl);
var Rechts = allHTML.substr(LinksZahl + selectedHTML.length, allHTML.length);
var Gesamt = Links + " <span style='background-color:yellow'>" + selectedHTML + "</span> " + Rechts;
document.all.FirstCol.innerHTML = Gesamt;
}
Hi !
I wrote this function in JavaScript
as far as I know it only works in IE
that doesnt matter to me because it's
supposed just to run on my intranet.
Here my question:
When I select for instance the word "deployment"
in my browser
and it is the second time in the text
its just the first "deployment" that will be
marked in yellow color.
I know indexof works also with a startposition
but I dont know how to find out where my selected
text starts.
FirstCol is the id of a tablecell
and so far it works perfect just with that
little problem
Thanks for your help
Moonrider
{
var selectedHTML = document.selection.createRange().htmlText;
alert(document.selection.createRange().selectionstart);
var allHTML = document.all.FirstCol.innerHTML;
var LinksZahl = allHTML.indexOf(selectedHTML, document.selstart);
var Links = allHTML.substr(0,LinksZahl);
var Rechts = allHTML.substr(LinksZahl + selectedHTML.length, allHTML.length);
var Gesamt = Links + " <span style='background-color:yellow'>" + selectedHTML + "</span> " + Rechts;
document.all.FirstCol.innerHTML = Gesamt;
}
Hi !
I wrote this function in JavaScript
as far as I know it only works in IE
that doesnt matter to me because it's
supposed just to run on my intranet.
Here my question:
When I select for instance the word "deployment"
in my browser
and it is the second time in the text
its just the first "deployment" that will be
marked in yellow color.
I know indexof works also with a startposition
but I dont know how to find out where my selected
text starts.
FirstCol is the id of a tablecell
and so far it works perfect just with that
little problem
Thanks for your help
Moonrider