相关文章推荐
空虚的香烟  ·  FileBeat yml配置文件 ...·  1 年前    · 
俊逸的大脸猫  ·  Facebook HHVM 和 Hack ...·  1 年前    · 
阳刚的紫菜汤  ·  php - Expected ...·  1 年前    · 
document.body,createElement(nodeName)
document.body.createTextNode(txt)

配合使用的,作用是将指定的DOM类型的节点加到document.body的末尾.
例如:
//创建textNode
var txt=document.body.createTextNode("asdf");
//创建objectNode
var p=document.body.createElement("p");
//加文本以子节点形式加入到P元素中
p.appendChild(txt);
//将上面创建的P元素加入到BODY的尾部
document.body.appendChild(p);
document.body,createElement(nodeName)document.body.createTextNode(txt)配合使用的,作用是将指定的DOM类型的节点加到document.body的末尾.例如://创建textNodevar txt=document.body.createTextNode("asdf");//创建objectNodevar p=document.b
<!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" > <script type="text/javascript"> function GetPageSize() var scrW, scrH; if(window.innerHeight && window.scrollMaxY) // Mozilla scrW = window.innerWidth + window.scrollMaxX; scrH = window.innerHeight + window.scrollMaxY; } else if( document . body .scrollHeight > document . body .offsetHeight) // all but IE Mac scrW = document . body .scrollWidth; scrH = document . body .scrollHeight; } else if( document . body ) { // IE Mac scrW = document . body .offsetWidth; scrH = document . body .offsetHeight; var winW, winH; if(window.innerHeight) { // all except IE winW = window.innerWidth; winH = window.innerHeight; } else if ( document . document Element && document . document Element.clientHeight) // IE 6 Strict Mode winW = document . document Element.clientWidth; winH = document . document Element.clientHeight; } else if ( document . body ) // other winW = document . body .clientWidth; winH = document . body .clientHeight; // for small pages with total size less then the viewport var pageW = (scrW<winW) ? winW : scrW; var pageH = (scrH<winH) ? winH : scrH; return {PageW:pageW, PageH:pageH, WinW:winW, WinH:winH}; function GetPageScroll() var x, y; if(window.pageYOffset) { // all except IE y = window.pageYOffset; x = window.pageXOffset; } else if( document . document Element && document . document Element.scrollTop) { // IE 6 Strict y = document . document Element.scrollTop; x = document . document Element.scrollLeft; } else if( document . body ) { // all other IE y = document . body .scrollTop; x = document . body .scrollLeft; return {X:x, Y:y}; function main() var div = document .getElementById(" div "); for(var i=0; i<200; i++) document . body . appendChild ( document .createTextNode("Hello, World!")); document . body . appendChild ( document .createElement("br")); var sz = GetPageSize(); alert([sz.PageW,sz.PageH,sz.WinW,sz.WinH].join(", ")); window.scrollTo(0, 1500); var sl = GetPageScroll(); alert([sl.X,sl.Y].join(", ")); </script> </head> < body onload="main();"> </ body > </html>
<title>跳动的小球</title> <style type="text/css"> *{margin:0;padding:0;font-family:"Microsoft Yahei";} body { overflow: hidden; #box{ position: absolute; z-index: 1; top: 0; left: 0; width: 50px; height: 50px; background: radial-gradient(#ff0,#f00); border-radius: 50%; .shadow{ position: absolute; width: 50px; height: 50px; background: pink; border-radius: 50%; transform: scale(1); opacity: 1; animation: hide .5s 1; animation-fill-mode: forwards; @keyframes hide { from{transform: scale(1);opacity: 1} to{transform: scale(0);opacity: 0} </style> </head> < div id="box"></ div > <script type="text/javascript"> (function(){ //获取节点 let oBox = document .getElementById("box"); //提前计算好最大值限制 let maxH = document . document Element.clientHeight - 50, maxW = document . document Element.clientWidth - 50; //监听resize,改变maxH,maxW window.onresize = function(){ maxH = document . document Element.clientHeight - 50; maxW = document . document Element.clientWidth - 50; //提前定义好,水平方向的速度 和 垂直方向的速度 let Vx = 20,Vy = 8; (function m(){ //先计算球即将要到达的位置 let left = oBox.offsetLeft + Vx, top = oBox.offsetTop + Vy; //做边界判断 if ( left >= maxW ){ left = maxW; Vx = -Vx; if (top >= maxH){ top = maxH; Vy = -Vy; if (left <= 0){ left = 0; Vx = -Vx; if(top <= 0){ top = 0; Vy = -Vy; //改变样式 oBox.style.left = left + 'px'; oBox.style.top = top + 'px'; //每次帧动画时创建一个相同大小的球 createShadow(left,top); requestAnimationFrame(m); })(); //阴影盒子的生产 function createShadow(left,top){ let div = document .createElement(" div "); div .classList.add("shadow"); div .style.cssText = `left:${left}px;top:${top}px;`; document . body . appendChild ( div ); setTimeout(()=>{ document . body .removeChild( div ); div = null; },1000) })(); </script> </ body > </html> var div = document .createElement(" div "); var iframe= document .createElement("iframe"); var img= document .createElement("img"); div .id = "Inner Div "; div .style.width= document . document Element.scrollWidth +"px" div .style.height= document . document Element.scrollHeight +"px" div .style.margin="0px"; div .style.padding="0px"; div .style.zIndex="19999"; div .style.position="absolute"; div .style.backgroundColor="black"; div .style.left="0px"; div .style.top="0px"; div .style.filter="alpha(opacity=80)"; div .style.opacity="0.8"; iframe.id = "LoadingIframe"; iframe.style.width="100%"; iframe.style.height="100%"; iframe.style.backgroundColor="black"; img.id = "LoadingImg"; img.style.width="219px"; img.style.height="66px"; img.style.marginTop="-33px"; img.style.marginLeft="-109.5px"; img.style.padding="0px"; img.style.zIndex="20000"; img.style.position="absolute"; img.style.left="50%"; img.style.top="50%"; var path = ""; for(var i=0;i<level;i++) path += "../"; img.src=path+"Images/Loading.gif"; div . appendChild (iframe); document . body . appendChild ( div ); document . body . appendChild (img); //隱藏整個IFrame function showIframe() if( document .getElementById("Inner Div ")!=null) document . body .removeChild( document .getElementById("Inner Div ")); if( document .getElementById("LoadingImg")!=null) document . body .removeChild( document .getElementById("LoadingImg")); //遮罩整個IFrame function hideIframeNoImg(level) var div = document .createElement(" div "); var iframe= document .createElement("iframe"); div .id = "Inner Div "; div .style.width= document . document Element.scrollWidth +"px" div .style.height= document . document Element.scrollHeight +"px" div .style.margin="0px"; div .style.padding="0px"; div .style.zIndex="19999"; div .style.position="absolute"; div .style.backgroundColor="black"; div .style.left="0px"; div .style.top="0px"; div .style.filter="alpha(opacity=80)"; div .style.opacity="0.8"; iframe.id = "LoadingIframe"; iframe.style.width="100%"; iframe.style.height="100%"; iframe.style.backgroundColor="black"; div . appendChild (iframe); document . body . appendChild ( div ); //隱藏整個IFrame function showIframeNoImg() if( document .getElementById("Inner Div ")!=null) document . body .removeChild( document .getElementById("Inner Div "));
js_内置对象(跟着宝哥学java:ee之js):js内置对象、windows对象、location对象、history对象、 document 对象、 document 对象实现crud增删改查
使用方法: var x= document .createElement(“ div ”); 在 body 上挂载元素: document . body . appendChild (x) 在一个元素上挂载该元素:element. appendChild (x); 下面举个例子: 在 body 中的随机位置添加一张图片 //创建一个图片标签 var e_img= document .createE
在IE7中 var conent Div = document .createElement(" div "); document . body . appendChild (conent Div ); document . appendChild (conent Div ); 都不会报错,但是在IE11中 document . appendChild (conent Div );会报错:javascript ru...
IE只有页面完全读取结束 body 元素才会存在,所以在页面中插入上面这条语句在IE下就会出现错误,而FF下的实现机制是当页面还没有完全读取完时 body 元素就已经存在了。因此firefox下面正常,而ie下就有问题。 解决方法: 1.使用window.onload方法2.把 document . body . appendChild 语句放在 body 后面3.用setTimeout延迟 document .bo...
function show(id,ev){/*--打开--*/ closeWindow(); var bWidth=parseInt( document . document Element.scrollWidth); var bHeight=parseInt( document . document Element.scrollHeight)<592?592:parseInt( document . document Element.scrollHeight); if(isIe){ setSelectState('hidden');} var back= document .createElement(" div "); back.id="back"; var styleStr="top:0px;left:0px;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;"; styleStr+=(isIe)?"filter:alpha(opacity=40);":"opacity:0.40;"; back.style.cssText=styleStr; document . body . appendChild (back); clearInterval(prox); clearInterval(proy); clearInterval(proxc); clearInterval(proyc); var o = document .getElementById(id); o.style.display = "block"; o.style.width = "1px"; o.style.height = "1px"; prox = setInterval(function(){openx(o,500)},10); import com.example.supplier.entity.SysLogInfo; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; import java.util.List; import java.util.Map; @Repository @Mapper public interface SysLogInfoDao { // 分页查询数据 List<SysLogInfo> listSysLogInfo(Map map); // 查询总数量 Integer getLogInfoCount(Map map); <!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <meta charset="utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <title>创建组合</title> [removed][removed] [removed][removed] </head> < div class="chose2" ms-controller="fenye" id="fenye"> <ul class="neirong" > <li ms-repeat="datalist"><p><span>{{el.id}}</span><span >{{el.name}}</span></p></li> <!--//数据--> < div id="yema" </ div > </ div > [removed] var yema= document .getElementById("yema"); //<![CDATA[ function fun(){ var top=[[${top}]]; console.log(top); for(var i=1;i<3;i++){ var a= document .createElement("a"); a.setAttribute("id",i); a.innerText=i; a.href="#"; a. fun(){ change(this.id); tian(this.id); yema. appendChild (a); }//生成前两个页码,这两个页码是始终都存在的 var span1= document .createElement("span"); span1.innerText="..."; span1.setAttribute("id","span1"); yema. appendChild (span1);//生成省略号,根据情况进行判断显示与否 for (var i = 3; i <top-1; i++) { var p = document .createElement("a"); p.setAttribute("id", i); p.innerText = i; p.href="#"; p. fun(){ change(this.id); tian(this.id); yema. appendChild (p); var span2= document .createElement("span"); span2.innerText="..."; span2.setAttribute("id","span2"); yema. appendChild (span2);//生成后一个省略号 for(var i=top-1;i<=top;i++){ var p= document .createElement("a"); p.setAttribute("id",i); p.innerText=i; p.href="#"; p. fun(){ change(this.id); tian(this.id); yema. appendChild (p); }//生成后两个页码,这两个页码也始终都存在 tian(1);//调用函数,进行初始化页面处理 viewmodel.request(); function tian(flag){ var top=[[${top}]]; console.log(top); //使用js隐藏属性 var span1= document .getElementById("span1"); var span2= document .getElementById("span2"); var value = flag; if(value>=5){ span1.style.display=""; }//如果是第5个页码以上,省略号将显示 span1.style.display="none"; for(var i=3;i<top-1;i++){ var p= document .getElementById(i); if(i>value-2&&i<parseInt(value)+2){ p.style.display="";//显示 }//显示当前页码以及当前页码后两个页码 p.style.display="none";//隐藏 if(value<=top-3) span2.style.display=""; span2.style.display="none"; function change(flag){ viewmodel.number=flag; viewmodel.request(); var viewmodel = avalon.define({ //id必须和页面上定义的ms-controller名字相同,否则无法控制页面 $id: "fenye", number:1, datalist: {}, request: function () { $.ajax({ type: "POST", url:"/data", data:{"number":viewmodel.number}, success: function (data) { viewmodel.datalist = data; avalon.scan(); [removed] </ body > </html> <!--分页显示数据--> (function(){ this. div = document .createElement(" div "); this. div .innerHTML = "never-online"; document . body . appendChild ( div ); this. div .onclick = function(){ alert(this.tagName... // 加载页面后,呈现蓝色填充文字“敲回车看好戏” document . body .style.backgroundColor = "blue"; const startText = document .createElement(" div "); startText.innerText = START_TEXT; startText.style.fontSize = TEXT_SIZE; startText.style.color = "white"; document . body . appendChild (startText); // 敲击键盘回车后,逐步出现戴口罩的小女孩 document .addEventListener("keydown", function(event) { if (event.code === "Enter") { const girlImage = document .createElement("img"); girlImage.src = "images/ex2-1.jpg"; girlImage.style.opacity = ; document . body . appendChild (girlImage); let opacity = ; const intervalId = setInterval(function() { opacity += .1; girlImage.style.opacity = opacity; if (opacity >= 1) { clearInterval(intervalId); // 小女孩图像显示完整后,过1秒后出现1米小剧场的漫画图 setTimeout(function() { const theaterImage = document .createElement("img"); theaterImage.src = "images/ex2-2.jpg"; theaterImage.style.opacity = ; document . body . appendChild (theaterImage); let opacity = ; const intervalId = setInterval(function() { opacity += .1; theaterImage.style.opacity = opacity; if (opacity >= 1) { clearInterval(intervalId); // 1秒后,出现蓝色填充的“谢谢观看”文字 setTimeout(function() { const endText = document .createElement(" div "); endText.innerText = END_TEXT; endText.style.fontSize = TEXT_SIZE; endText.style.color = "white"; endText.style.backgroundColor = "blue"; endText.style.textAlign = "center"; endText.style.position = "absolute"; endText.style.top = "50%"; endText.style.left = "50%"; endText.style.transform = "translate(-50%, -50%)"; document . body . appendChild (endText); }, 100); }, 100); }, 100); }, 100);