==================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>
<!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>
解决方案 »
- jquery 动态添加select的option 不能使用$('select').val("a")
- 这段代码如何解密?
- 鼠标经过弹出三级菜单,鼠标划出菜单隐藏,求大家帮忙!
- js定时器问题?
- 勾选table一行的checkbox时候,如何把这一行的值添加到父页面的table中
- 超级怪异的问题,当在一个文件中定义全局变量的时候,有些变量居然是对象类型的
- 为什么不能用dojo
- 动态改变tr的颜色
- 如何获得屏幕的中间点?分全送了
- 怎样控制弹出窗口高度小于50
- 使用regsvr32.exe aaa.dll 没有找到dllregisterserver输入点,无法注册这个文件 是什么原因,急在线等
- 能帮我把懲标做成旋转或者其他样式吗
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();
ifa2.contentWindow.document.open();
ifa2.contentWindow.document.write("d");
ifa2.contentWindow.document.close()
ifa2.focus();这种情况下写入某些浏览器会无法调整字体大小.