Here's an example from Microsoft:
====================================
var sel = document.selection;
if (sel!=null) {
var rng = sel.createRange();
if (rng!=null)
rng.pasteHTML('<HTML></HTML>');
}
====================================
Problems:
1) The above causes an "unspecified error" if the selection is null. It would be nice if microsoft's error could be removed.
2) What I'm really looking for is a means of pasting HTML beside the cursor when the user has made no selection.
Any ideas?
Lastly, can anyone describe clearly the difference between a text range and a control range? I'm under the impression that the former is plain text, and the latter is HTML tags but I'm not sure.
====================================
var sel = document.selection;
if (sel!=null) {
var rng = sel.createRange();
if (rng!=null)
rng.pasteHTML('<HTML></HTML>');
}
====================================
Problems:
1) The above causes an "unspecified error" if the selection is null. It would be nice if microsoft's error could be removed.
2) What I'm really looking for is a means of pasting HTML beside the cursor when the user has made no selection.
Any ideas?

Lastly, can anyone describe clearly the difference between a text range and a control range? I'm under the impression that the former is plain text, and the latter is HTML tags but I'm not sure.