一个编辑器想实现的功能 如果不是ABC呢。如果要改成CAB呢这种需求太那个了把~~~~选中文字出现编辑框倒是可以 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我那是打个比方...当然不会肯定是ABC...我的意思是任意文字都这样... <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=gb2312" /> <title>Editor</title> </head> <body> <table width="700px" border="0" cellpadding="0" cellspacing="1" align="center"> <tr><td><a href="#" onclick="InsertLine()">插入删除线</a></td></tr> <tr><td> <iframe id="Editor" width="100%" height="300px" marginheight="0" marginwidth="0" frameborder="1"></iframe> </td></tr> </table><script>var ns=navigator.appName=="Netscape";var Editor,EditorDoc;window.onload=function(){ Editor=document.getElementById("Editor").contentWindow; InitIframe("gb2312"); EditorDoc=Editor.document;}function InitIframe(charset){ Editor.document.open(); Editor.document.write("<html>"); Editor.document.write("<head>"); Editor.document.write("<style type='text/css'>body{font-size:12pt;}</style>"); Editor.document.write("</head>"); Editor.document.write("<body></body>"); Editor.document.write("</html>"); Editor.document.close(); Editor.document.body.contentEditable="true"; Editor.document.designMode="On"; Editor.document.charset=charset; Editor.focus();}function InsertLine(){ var r=ns?EditorDoc.createRange():EditorDoc.selection.createRange(); var txt=ns?EditorDoc.getSelection():r.text; if(txt==""){alert('请先选择删除的文字!');return;} var v=prompt("输入替换的值",""); while(v=="")v=prompt("输入替换的值",""); if(ns){//ff需要2步完成 var s=document.createElement("strike");s.innerHTML=v; Editor.window.getSelection().getRangeAt(0).surroundContents(s); Editor.focus(); var sp=document.createElement("span");sp.style.color='red';sp.innerHTML=v; EditorDoc.body.insertBefore(sp,s.nextSibling); }//ie使用pasteHTML就搞定了 else r.pasteHTML("<strike>"+txt+"</strike><span style='color:red'>"+v+'</font>');}</script> </body></html> 页面解析json串 火狐 JS给Flash传值 错误:length 为空或不是对象 js拖放元素在ff下的小问题(- -|| 急。。) javascript 调ocx求救! 用jquery 怎么控制girdview第一行中的 [选择] button 不表现..或 失效. 网站中有很多页面是通过js跳转的,怎样获取js中的URL? 这段js怎么改成jquery写啊 CSDN左边菜单栏疑问! JavaScript有哪些帮助文档? iframe设置name的问题 提问.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>Editor</title>
</head>
<body>
<table width="700px" border="0" cellpadding="0" cellspacing="1" align="center">
<tr><td><a href="#" onclick="InsertLine()">插入删除线</a></td></tr>
<tr><td>
<iframe id="Editor" width="100%" height="300px" marginheight="0" marginwidth="0" frameborder="1"></iframe>
</td></tr>
</table>
<script>
var ns=navigator.appName=="Netscape";
var Editor,EditorDoc;
window.onload=function(){
Editor=document.getElementById("Editor").contentWindow;
InitIframe("gb2312");
EditorDoc=Editor.document;
}
function InitIframe(charset){
Editor.document.open();
Editor.document.write("<html>");
Editor.document.write("<head>");
Editor.document.write("<style type='text/css'>body{font-size:12pt;}</style>");
Editor.document.write("</head>");
Editor.document.write("<body></body>");
Editor.document.write("</html>");
Editor.document.close();
Editor.document.body.contentEditable="true";
Editor.document.designMode="On";
Editor.document.charset=charset;
Editor.focus();
}
function InsertLine(){
var r=ns?EditorDoc.createRange():EditorDoc.selection.createRange();
var txt=ns?EditorDoc.getSelection():r.text;
if(txt==""){alert('请先选择删除的文字!');return;}
var v=prompt("输入替换的值","");
while(v=="")v=prompt("输入替换的值","");
if(ns){//ff需要2步完成
var s=document.createElement("strike");s.innerHTML=v;
Editor.window.getSelection().getRangeAt(0).surroundContents(s);
Editor.focus();
var sp=document.createElement("span");sp.style.color='red';sp.innerHTML=v;
EditorDoc.body.insertBefore(sp,s.nextSibling);
}
//ie使用pasteHTML就搞定了
else r.pasteHTML("<strike>"+txt+"</strike><span style='color:red'>"+v+'</font>');
}
</script>
</body>
</html>