像一下这些操作:
var textSelection = document.selection.createRange();
textSelection.execCommand('Bold');
求高手赐教这些方法和操作,在firefox下是怎么用的,因为上面那些代码好像只有在IE下才能正常运行。
我是想做个在线日志编写的模块,还会用到哪些属性或方法,请不吝赐教!
var textSelection = document.selection.createRange();
textSelection.execCommand('Bold');
求高手赐教这些方法和操作,在firefox下是怎么用的,因为上面那些代码好像只有在IE下才能正常运行。
我是想做个在线日志编写的模块,还会用到哪些属性或方法,请不吝赐教!
if (!doc) doc = document;
var q;
try {
if (doc.parentWindow && doc.parentWindow.getSelection) q = doc.parentWindow.getSelection();
else if (doc.getSelection) q = doc.getSelection();
else if (doc.selection) q = doc.selection.createRange().text;
} catch(e) {} if (!q) {
var iframes = doc.getElementsByTagName("iframe");
for (var i = 0; i < iframes.length; i++) {
try {
q = this.getSelectionText(iframes[i].contentWindow.document);
} catch(e) {}
if (q) return q;
}
}
return q;
}
获得选中文字函数
这个也可以参考一下