<div id="aa">就是个demo<div>
<script language="javaScript">
var div = document.getElementById("aa");
div.onmouseup = function () {
var userSelection;
if (window.getSelection) {
// 现代浏览器
userSelection = window.getSelection();
userSelection.getRangeAt(0).deleteContents();
userSelection.getRangeAt(0).insertNode(document.createTextNode('text'));
} else if (document.selection) {
// IE浏览器
userSelection = document.selection.createRange();
userSelection.text = 'test'
}
};
</script>多看下api,楼主,IE的selection和标准浏览器接口不一样:selection对象中文API
<script language="javaScript">
var div = document.getElementById("aa");
div.onmouseup = function () {
var userSelection;
if (window.getSelection) {
// 现代浏览器
userSelection = window.getSelection();
userSelection.getRangeAt(0).deleteContents();
userSelection.getRangeAt(0).insertNode(document.createTextNode('text'));
} else if (document.selection) {
// IE浏览器
userSelection = document.selection.createRange();
userSelection.text = 'test'
}
};
</script>多看下api,楼主,IE的selection和标准浏览器接口不一样:selection对象中文API
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货