[thelist] Textarea formating
dave gray
dascott at wam.umd.edu
Fri Aug 11 08:22:18 CDT 2000
actually, this should be:
function makeBold(){
var fullText = document.forms[0].fred.value;
// the function on the next line probably doesn't exist...
// i forget how to do that 'get the user-selected text
// from the browser' thing...
var selectedText = document.selectedText.createRange();
var whatToMatch = new RegExp(selectedText);
// the important change was here... there would be no .leftContext
// or .rightContext the way i did it before DOH
var resultArray = whatToMatch.exec(fullText);
newText = whatToMatch.leftContext + "<b>" + whatToMatch.lastMatch +
"</b>" + whatToMatch.rightContext;
document.forms[0].fred.value=newText;
}
...
<textarea name=fred></textarea>
<a href="javascript:void(makeBold())">make selected text bold</a>
if anyone really cares :)
-dave
> function makeBold(){
> var selectedText = "";
> var whatToMatch = new RegExp(selectedText);
> var resultArray = whatToMatch.exec(selectedText);
> newText = whatToMatch.leftContext + "<b>" + whatToMatch.lastMatch +
> "</b>" + whatToMatch.rightContext;
> document.forms[0].fred.value=newText;
> }
>
> ...
>
> <textarea name=fred></textarea>
> <a href="javascript:void(makeBold())">make selected text bold</a>
>
> -dave
>
> ps- O'Reilly's Dynamic HTML rocks!
>
>
> > > the heart of all of these scripts. Would I therefore be
> > > right in suspecting
> > > that you can only do this in IE, and that it's just not possible in
> > > Netscape? If it is possible could someone point me in the
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !
>
More information about the thelist
mailing list