I am developing an underline bookmarklet. It was designed to work in any text box but it only seems to work in Yahoo mail. I have no idea why. I have included it below. Line breaks and comments have been added. In reality it is one line that goes in the address of the bookmark. When it works inputString has a value. When it doesn’t work (which is everywhere but Yahoo mail) inputString is blank.
It is available for testing at [url]http://dmmarks.com/bookmarklets.html
[CODE]javascript:
/* function to convert HTML entities to text */
function%20get_ents(str)
{var%20temp=document.createElement(‘pre’);
temp.innerHTML=str;
return%20temp.firstChild.nodeValue;};
/* get the selected text */
inputString=document.getSelection().getRangeAt(0); <—– problem seems to be here
inputChar=”;
outputChar=”;
/* convert to string so length will work */
selectedText%20=%20inputString.toString();
/* add the underline charaters */
for(i=0;i<selectedText.length;i++)
{outputChar=outputChar+selectedText.charAt(i).concat(‘%CC%B2’)};
/* replace the selected text */
inputString.deleteContents();
inputString.insertNode(document.createTextNode(get_ents(outputChar)));
void(0);