//获取选中的内容
function getSelectedText(id) {
var select_field = document.getElementById(id);
word = '';
if (document.selection) {
var sel = document.selection.createRange();
if (sel.text.length > 0) {
word = sel.text;
}
} /*ie浏览器*/
else if (select_field.selectionStart || select_field.selectionStart == '0') {
var startP = select_field.selectionStart;
var endP = select_field.selectionEnd;
if (startP != endP) {
word = select_field.value.substring(startP, endP);
}
} /*标准浏览器*/
return word;
}
//为选中的内容进行加粗改变前景色设置
function ChangeCss(id) {
var t = getSelectedText(id);
if (t.length > 0) {
var content = document.getElementById(id).innerHTML;
content = content.replace(t, "" + t + "");
document.getElementById(id).innerHTML = content;
}
}
NBA要闻:在今天马刺118-103战胜开拓者的比赛....