==================demo.html============================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn">
<head>
<!--缓存信息-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="gb2312" />
<!--编码信息-->
<meta name="robots" content="all" />
<!--机器人爬虫-->
<meta name="author" content="Tencent-ISRD" />
<meta name="Copyright" content="Tencent" />
<meta name="Description" content="TommyFan" />
<meta name="Keywords" content="TommyFan,微格式,microformats,hCard" />
<title>微格式 microformats hCard - tommyfan.com</title>
<link rel="stylesheet" rev="stylesheet" href="css/hCard_main.css" type="text/css" media="screen" />
<!--[if IE 7]>
<link href="css/ie7.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<!--[if IE 6]>
<link href="css/ie6.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<!--[if lt IE 6]>
<link href="css/ie6lt.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
<!--网站icon-->
<!--
<link rel="alternate" type="application/rss+xml" title="RSS news feed" href="rss.xml" />
-->
<!--RSS连接-->
</head>
<body>
<div id="container">原来内容</div>
<script type="text/javascript">
window.onload = function(){
//建立iframe
var ifa =document.createElement("iframe");
ifa.src="editor.htm?d"+document.getElementById('container').innerHTML;
ifa.frameBorder="no";
ifa.allowTransparency="true";
ifa.width="100%";
ifa.height="111";
document.getElementById('container').innerHTML = '';
ifa2 = document.getElementById('container').appendChild(ifa);

//编辑模式
ifa2.contentWindow.document.designMode="on";
ifa2.contentWindow.document.contentEditable=true;

//改变html
ifa2.contentWindow.document.getElementById('b1').innerHTML = "d";
ifa2.contentWindow.focus();
}
</script>
</body>
</html>
==================editor.html============================
<html>
<head>
<style>
*{font-size:12px;}
html,body{height:100%;overflow:hidden;}
</style>
<script type="text/javascript">
</script>
</head>
<body id="b1"></body>
</html>

解决方案 »

  1.   

    //编辑模式
    ifa2.contentWindow.document.designMode="on";
    ifa2.contentWindow.document.contentEditable=true;//改变html
    ifa2.contentWindow.document.open();
    ifa2.contentWindow.document.write("d");
    ifa2.contentWindow.document.close()
    ifa2.focus();
      

  2.   

    //改变html
    ifa2.contentWindow.document.open();
    ifa2.contentWindow.document.write("d");
    ifa2.contentWindow.document.close()
    ifa2.focus();这种情况下写入某些浏览器会无法调整字体大小.
      

  3.   

    $(function(){alert("UP,MARK,JF!!");});
      

  4.   

    $(function(){alert("UP,MARK,JF!!");});