Hi
I'm trying to write a system in which you can highlight some text in a form
box, click a button (or press a key combination) and the text highlighted
gets surrounded by a given html tag.
The following works fine in IE on a PC:
txt = document.selection.createRange().text;
document.selection.createRange().text = '<b>' + txt + '</b>';
I gather that Safari "doesn't do" document.selection.createRange().text, so
I'm using window.getSelection() instead.
I can use the following to demonstrate for myself that safari is "seeing"
the highlighted text in the form box:
txt = window.getSelection();
alert(txt);
window.getSelection() = '<b>' + txt + '</b>';
The last line is doing nothing though. I've also tried:
window.getSelection().text = '<b>' + txt + '</b>';
but no luck.
Any ideas how I can write HTML tags around some highlighted text in Safari?
Thanks for any help,
Julian