Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Intuitive approach
04-10-2009, 07:19 PM #1
- Join Date
- Mar 2009
- Thanked 0 Times in 0 Posts
At present I am working on an annotaion tool for my thesis. Basically the user is able to select any text on a web page and change its text color background. the text and text color background are stored in a database so when the user re-vists the same page, the highlights re-appear. I am stuck with these 2 issues:
1) My highlight function highlights the 1st instance of the text selected.
2) When the page re-loads, it searches the page and highlight the first instance of the text. So if I highlight "the", on re-load it will find the first "the" and not necessarily the word or phrase I selected at the particualr postition.
Can anyone please help?
this is my code
var workArea = "";
workArea = content.document.getElementsByTagName('body');
var openTag = '<span style="background-color: 'red'\'">';
var closeTag = '</span>';
workText = content.getSelection().getRangeAt(0);
var currReplace = new RegExp("("+workText+")");
workArea.innerHTML = workArea.innerHTML.replace(currReplace, openTag+"$1"+closeTag);
04-10-2009, 07:32 PM #2
- Join Date
- Feb 2009
- Wheeling, IL
- Thanked 62 Times in 60 Posts
Why cross-post? And in the same forum at that... seriously, try and read the rules regarding posting here.
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.
How to ask smart questions?