<article> <section> <h2>标题一</h2> <p>内容一</p> </section> <section> <h2>标题二</h2> <p>内容二</p> </section> </article>
<article> <header>简介一</header> <p>内容一</p> <header>简介二</header> <p>内容二</p> </article>
<nav > <a href="http://www.baidu.com">百度</a> <a href="http://www.google.com">Google</a> <a href="http://www.sogou.com">搜狗</a> </nav>
<ul> <li>音乐</li> <li>程序设计 <ul> <li>java</li> <li>c++</li> <li>c#</li> </ul> </li> <li>体育</li> </ul> 这类标签可以嵌套。 <ol start="2" > <li>***思想</li> <li>三个代表</li> <li>八荣八耻</li> </ol> ol新增了start和reversed两个属性,前者定义开始的编号,后者用于设置列表是否反序 <dl> <dt>html5</dt> <dd>新一代html</dd> <dt>jquery</dt> <dd>前端框架</dd> <dd>支持移动端</dd> </dl>
dt后面可以有多个dd
17日至18日,×××在河南省委书记郭庚茂、省长<mark>谢伏瞻</mark>陪同下,深入农村和窗口服务单位,同干部群众交流座谈、听取意见和建议,
实地指导兰考县教育实践活动。
</div>
<input type="text" list="listWork" /> <datalist id="listWork"> <option value="c++"></option> <option value="java"></option> <option value="javascript"></option> </datalist>
<input type="file" name="myfile" id="myfile" multiple />
<input type="file" name="myfile" id="myfile" multiple onchange="getFileList(this.files)" /> js代码: function getFileList(fs){ for(var i=0;i<fs.length;i++){ var f=fs[i]; //文件名 文件类型 文件大小(字节) alert(f.name+" "+f.type+" "+ f.size); } }
function previewImgs(fs){ if(typeof FileReader == 'undefined'){ alert("浏览器不支持FileReader对象"); } var previewDiv=document.getElementById("previewDiv"); for(var i=0;i<fs.length;i++){ var f=fs[i]; var reader=new FileReader(); reader.readAsDataURL(f); reader. previewDiv.innerHTML+="<img src='"+ e.target.result+"' /><br/>"; } } }
function readTxt(fs){ if(typeof FileReader == 'undefined'){ alert("浏览器不支持FileReader对象"); } var txtDiv=document.getElementById("txtDiv"); for(var i=0;i<fs.length;i++){ var f=fs[i]; var reader=new FileReader(); reader.readAsText(f); reader. txtDiv.innerHTML+= "<pre>"+e.target.result+"</pre>"; } } }
<div id="uploadDiv" style="border: 1px solid;height: 200px" ondrop="dropFile(event)" ondragenter="return false" ondragover="return false"> 上传图片 </div> <br/> <div id="imgDiv"> 这里预览图片 </div> javascript代码: function fileUpload(fs){ var imgDiv=document.getElementById("imgDiv"); for(var i=0;i<fs.length;i++){ var f=fs[i]; var reader=new FileReader(); reader.readAsDataURL(f); reader. // alert(e.target.result); imgDiv.innerHTML += "<img src='"+e.target.result+"' />"; } } } function dropFile(e){ //alert(e.dataTransfer); fileUpload(e.dataTransfer.files); //停止事件传播 e.stopPropagation(); //阻止默认事件的发生,否则拖拽上去后会触发其他拖拽事件 e.preventDefault(); }
function uploadForm(){ var formData=new FormData(); for(var i=0;i<files.length;i++){ var f=files[i]; formData.append(f.name,f); } var xhr=new XMLHttpRequest(); xhr.onreadystatechange=function(){ if(xhr.readyState==4 && xhr.status==200){ alert("上传成功"); } } xhr.open("post","<%=path%>/upservlet",true); xhr.send(formData); } servlet核心代码如下: FileItemFactory factory=new DiskFileItemFactory(); ServletFileUpload upload=new ServletFileUpload(factory); List<FileItem> list=upload.parseRequest(request); 处理代码省略...
function videoProgress(_this){ var stateDiv=document.getElementById("stateDiv"); var state=_this.networkState; if(state==0){ stateDiv.innerHTML="正在初始化"; } if(state==1){ stateDiv.innerHTML="数据加载完成"; } if(state==2){ stateDiv.innerHTML="正在加载中"; } if(state==3){ stateDiv.innerHTML="数据加载失败"; } }
var arrtype=["audio/mov",'audio/mp4;codecs="mp4a.40.2"']; var myvideo=document.getElementById("myvideo"); for(var i=0;i<arrtype.length;i++){ alert(myvideo.canPlayType(arrtype[i])); }
html:<canvas id="cnvMain" width="280px" height="190px"></canvas> javascript: function pageload(){ var cnv=document.getElementById("cnvMain"); //得到上下文环境 var ctx=cnv.getContext("2d"); //设置背景色 ctx.fillStyle="red"; //矩形参数(x,y,width,height) ctx.fillRect(10,50,150,80); }
<canvas id="cnv" width="250px" height="180px"></canvas> javascript: var cnv=document.getElementById("cnv"); var ctx=cnv.getContext("2d"); //起点坐标 ctx.moveTo(100,50); //终点坐标 ctx.lineTo(100,100); ctx.lineTo(200,300); ctx.lineWidth=3; ctx.stroke();
html:<canvas id="cnv" width="280px" height="190px"></canvas> javascript: function createArc(){ var cnv=document.getElementById("cnv"); var ctx=cnv.getContext("2d"); //清除画布原有图形 ctx.clearRect(0,0,280,190); //开始画实体图 ctx.beginPath(); //参数:x坐标,y坐标,半径,开始角度,结束角度,是否按顺时针绘制 ctx.arc(60,60,50,0,Math.PI*2,true) //关闭 ctx.closePath(); //填充背景色 ctx.fillStyle="red"; //填充 ctx.fill(); }
oadb.transaction(function(tx){ tx.executeSql("create table if not exists userinfo (toid int,username text ,age int )"); }, function(){}, function(){ alert("表创建成功"); });
var toid=parseInt(document.getElementById("toid").value); var username=document.getElementById("username").value; var age=parseInt(document.getElementById("age").value); var oadb=window.openDatabase("oa","1.0","OA管理系统",1024*1024); oadb.transaction(function(tx){ tx.executeSql("insert into userinfo values(?,?,?)",[toid,username,age], function(){ alert("添加成功"); } ); }); 7.2.2.3 删除数据 var oadb=window.openDatabase("oa","1.0","OA管理系统",1024*1024); oadb.transaction(function(tx){ tx.executeSql("delete from userinfo where toid=?",[toid], function(){ alert("删除成功"); } ); }); 修改同新增/删除,此处不再赘述 7.2.2.3 查询数据 oadb.transaction(function(tx){ tx.executeSql("select * from userinfo",[], function(tx,rs){ for(var i=0;i<rs.rows.length;i++){ alert(rs.rows.item(i).toid+" "+rs.rows.item(i).username+" "+rs.rows.item(i).age); } } ); });
属性值描述 latitude 纬度 longitude 经度 accuracy 地理位置精确度 altitudeAccuracy 海拔精确度 heading 前进方向 speed 前进速度(米/秒) altitude 海拔高度
code值描述 0未知错误 1用户拒绝了定位服务 2没有获取正确的地理位置 3获取超时
window.navigator.geolocation.getCurrentPosition(function(pos){ alert("纬度:"+pos.coords.latitude); alert("经度:"+pos.coords.longitude); //alert("当前经纬度的精度:"+pos.coords.accuracy); },function(error){ alert(error.code+" "+error.message); },{ timeout:1000 });
var loca=document.getElementById("locaDiv"); var watchId=navigator.geolocation.watchPosition(function(pos){ loca.innerHTML="经纬度:("+pos.coords.latitude+","+pos.coords.longitude+","+pos.coords.speed+")"; navigator.geolocation.clearWatch(watchId); },function(){});
js <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=zh-CN"></script>
function getMap(la,lon,divid){ //创建一个中心点 var centerLL= new google.maps.LatLng(la,lon); var mapOptions = { center: centerLL, zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP }; //渲染的位置 var map = new google.maps.Map(document.getElementById(divid), mapOptions); //撒点 var marker = new google.maps.Marker({ position: centerLL, title:"我在这里" }); marker.setMap(map); }
<div id="contentDiv"></div> <input type="text" id="num" name="num" /> <br> <input type="button" value="提交" <br> <iframe id="idFrm" src="postMessage2.html"></iframe>
var originUrl="http://localhost:63342"; window.addEventListener('message',function(event){ if(event.origin==originUrl){ document.getElementById("contentDiv").innerHTML=event.data; } },false) function sendClick(){ var num=document.getElementById("num").value; document.getElementById("idFrm").contentWindow.postMessage(num,originUrl); }
var originUrl="http://localhost:63342"; window.addEventListener('message',function(event){ if(event.origin==originUrl){ var mydata=event.data; event.source.postMessage(mydata+" hello",event.origin); } },false);
<input type="text" name="username" id="username" /> <br/> <input type="button" value="提交" <br/> <div id="contentDiv"></div>
function sendMsg(){ var contentDiv=document.getElementById("contentDiv"); var username=document.getElementById("username").value; //创建socket对象 var socket=new WebSocket("ws://localhost:1998"); //开启socket socket.onopen=function(event){ alert("开启"); } //接收数据 socket.onmessage=function(event){ contentDiv.innerHTML=event.data; } //关闭连接 socket.onclose=function(event){ contentDiv.innerHTM="关闭了" } }