<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>+ =</title>
<script type="text/javascript">
function init() {
var html = '<html><head>\n'
+ '<style>\n'
+ 'p { margin:2pt 2pt 2pt 2pt; }\n'//改变它改变行距
+ '</style>\n'
+ '</head>\n'
+ '<body contenteditable="true" topmargin=1 leftmargin=1>'
+ 'aaaaaa'
+ '</body>\n'
+ '</html>\n';
var editdoc = document.all["MsgFrame"].contentWindow.document;
editdoc.open();
editdoc.write(html);
editdoc.close();
}
</script></head>
<body onload="init()">
<form>
<iframe style="width: 100%; height:100;line-height:30px;" marginwidth="0" marginheight="0" frameborder="1" id="MsgFrame" src="about:blank"></iframe>
</form>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>+ =</title>
<script type="text/javascript">
function init() {
var html = '<html><head>\n'
+ '<style>\n'
+ 'p { margin:2pt 2pt 2pt 2pt; }\n'//改变它改变行距
+ '</style>\n'
+ '</head>\n'
+ '<body contenteditable="true" topmargin=1 leftmargin=1>'
+ 'aaaaaa'
+ '</body>\n'
+ '</html>\n';
var editdoc = document.all["MsgFrame"].contentWindow.document;
editdoc.open();
editdoc.write(html);
editdoc.close();
}
</script></head>
<body onload="init()">
<form>
<iframe style="width: 100%; height:100;line-height:30px;" marginwidth="0" marginheight="0" frameborder="1" id="MsgFrame" src="about:blank"></iframe>
</form>
</body>
</html>
你的方法不行的,实现不了的
function init() {
var html = ' <html > <head >\n'
+ ' </head >\n'
+ ' <body style="line-height:40px;" >'
+ 'aaaaaa'
+ ' </body >\n'
+ ' </html >\n';
var editdoc = document.all[ "MsgFrame "].contentWindow.document;
editdoc.open();
editdoc.write(html);
editdoc.close();
}
</script >
用这种方式试出来了.