追加顶层DIV 有没有一个方法能够实现追加一个div,并且包容网页body内的所有代码? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><script>window.onload=function(){ var div=document.createElement("div"); div.innerHTML=document.body.innerHTML; document.body.innerHTML=""; document.body.appendChild(div);};</script><body>ssss</body></html> 这个应该你是要的<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>无标题文档</title><style type="text/css">#topDiv{ position:absolute; z-index:3; width:100%;height:100%;background:#000; display:none;top:0;left:0;}#topDiv div{position:absolute; z-index:2;width:500px;height:500px; margin:-250px;left:50%;top:50%;padding:0;background:#fff;}#topDiv div textarea{width:100%;height:100%;}</style><script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script><script type="text/javascript"> $(function() { $('#show').click(function() { $('body').after('<div id="topDiv"></div>'); $('#topDiv').fadeTo('slow', 0.5, function() { $(this).html('<div><textarea>' + $('body').html() + '</textarea></div>'); }); }); })</script></head><body><a id="show">Top Div</a><p>abcdefg</p><dl><dt>abcdefg</dt><dd>abcdefg</dd><dd>abcdefg</dd><dl><h1>1111</h1><h2>2222</h2></body></html> var d=document.createElement("div"),childs=document.body.childNodes,len=childs.length,i=0;for(;i<len;i++){ d.appendChild(childs[i]);}document.body.appendChild(d); 其实我要做的效果是新增一个最大容器的DIV,然后通过滤镜把网页内当前的内容旋转90°1L的方法我最早也这么想的,只是认为开销太大 关于IE10的困扰 jquery ui 的 resizable 如何限制子.col不超出父.box? js控制网页播放器的问题? 如何,做一个三级菜单,用弹出层实现!每一级都是弹出一个层! 100分请教元素定位问题: 动态创建一个div,使这个div的下面紧贴页面最底端,可以做到么? 请问在 ASP 里面怎样获取鼠标的点击内容? canvas 改变图片颜色 为什么不能打印出所有的RGB颜色呢? 如何得到div(层)的id??? 用IE浏览时能否改变正在运行的脚本变量值? 【原创】ImageZoom 图片放大效果 问下JavaScript Web UI 库是什么
<script>
window.onload=function(){
var div=document.createElement("div");
div.innerHTML=document.body.innerHTML;
document.body.innerHTML="";
document.body.appendChild(div);
};
</script>
<body>ssss
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题文档</title>
<style type="text/css">
#topDiv{ position:absolute; z-index:3; width:100%;height:100%;background:#000; display:none;top:0;left:0;}
#topDiv div{position:absolute; z-index:2;width:500px;height:500px; margin:-250px;left:50%;top:50%;padding:0;background:#fff;}
#topDiv div textarea{width:100%;height:100%;}
</style>
<script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$('#show').click(function() {
$('body').after('<div id="topDiv"></div>');
$('#topDiv').fadeTo('slow', 0.5, function() {
$(this).html('<div><textarea>' + $('body').html() + '</textarea></div>');
});
});
})
</script>
</head>
<body>
<a id="show">Top Div</a>
<p>
abcdefg
</p>
<dl>
<dt>abcdefg</dt>
<dd>abcdefg</dd>
<dd>abcdefg</dd>
<dl>
<h1>1111</h1>
<h2>2222</h2>
</body>
</html>
childs=document.body.childNodes,
len=childs.length,i=0;
for(;i<len;i++){
d.appendChild(childs[i]);
}
document.body.appendChild(d);