标签:javascript
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>富文本编辑,采用iframe嵌入的方法</title> </head> <body> <iframe name="richedit" style="height:200px;width:300px;"src="blank.html"></iframe> <br/> <button onclick="bold()">加黑</button> <button onclick="italic()">斜体</button> <script> window.onload=function(){ frames["richedit"].document.designMode="on"; } function bold(){ frames["richedit"].document.execCommand("bold",false,null); } function italic(){ frames["richedit"].document.execCommand("italic",false,null); } </script> </body> </html>
另外一个空白frame是一个简单的空白blank.html,放在同一目录下即可
<!doctype html> <head> <title></title> </head> <body> </body> </html>
标签:javascript
原文地址:http://blog.csdn.net/zjc/article/details/41527773