Web Analytics Made Easy -
StatCounter Intuitive approach - CodingForum


No announcement yet.

Intuitive approach

  • Filter
  • Time
  • Show
Clear All
new posts

  • Intuitive approach

    Hi guys,
    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')[0];
    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);

  • #2
    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?