|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
历经多年来的停滞不前,如今全球信息网联盟(WorldWideWebConsortium,W3C)重拾HTML标准化。破洛洛文章简介:HTML5全屏API,全屏扫瞄图片。
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>html5-fullscreen-api</title>
<style>
*{margin:0;padding:0}
img{display:block;margin:0auto}
.imgContainer:-webkit-full-screen{
width:100%;height:100%;background:#060;overflow:hidden;background:#000;text-align:center;
position:fixed;
left:0;top:0;
display:table-cell;
bottom:0;right:0;
}
.imgContainer:-moz-full-screen{
width:100%;height:100%;background:#060;overflow:hidden;background:#000;text-align:center;
position:fixed;
left:0;top:0;
bottom:0;right:0;
display:table-cell;
vertical-align:middle
}
.imgContainer:-webkit-full-screenimg{max-width:100%;display:inline-block;vertical-align:middle;cursor:url("http://a.xnimg.cn/n/apps/photo/modules/photo-view/CSSimg/zoomOut.cur"),auto;
}
.imgContainer:-moz-full-screenimg{max-width:100%;display:inline-block;vertical-align:middle;cursor:url("http://a.xnimg.cn/n/apps/photo/modules/photo-view/cssimg/zoomOut.cur"),auto;
}
</style>
<scripttype="text/javascript">
(function(){
varfullScreenApi={
supportsFullScren:false,
isFullScreen:function(){returnfalse;},
requestFullScreen:function(){},
cancelFullScreen:function(){},
prefix:
}
browserPrefixes=webkitmozomskhtml.split();
if(typeofdocument.cancelFullScreen!=undefined){
fullScreenApi.supportsFullScren=true
}
else{
for(vari=0,il=browserPrefixes.length;i<il;i++){
fullScreenApi.prefix=browserPrefixes[i];
if(typeofdocument[fullScreenApi.prefix+CancelFullScreen]!=undefined){
fullScreenApi.supportsFullScreen=true;
break;
}
}
}
//假如扫瞄撑持全屏
if(fullScreenApi.supportsFullScreen){
fullScreenApi.fullScreenEventName=fullScreenApi.prefix+fullscreenchange;
fullScreenApi.isFullScreen=function(){
switch(this.prefix){
case:
returndocument.fullScreen
casewebkit:
returndocument.webkitIsFullScreen
default:
returndocument[this.prefix+FullScreen]
}
}
fullScreenApi.requestFullScreen=function(el){
return(this.prefix===)?el.requestFullScreen():el[this.prefix+RequestFullScreen]();
}
fullScreenApi.cancelFullScreen=function(el){
return(this.prefix===)?el.cancelFullScreen():el[this.prefix+CancelFullScreen]();
}
}
window.fullScreenApi=fullScreenApi;
})()
</script>
</head>
<body>
<h1align="center"></h1>
<divclass="imgContainer">
<ahref="javascript:void(0)">
</a></div>
<scripttype="text/javascript">
window.onload=function(){
if(window.fullScreenApi.supportsFullScreen){
varimgContainer=document.getElementsByTagName(div);
varimgsLen=imgContainer.length;
for(vari=0;i<imgsLen;i++){
imgContainer[i].addEventListener(click,function(){
if(!fullScreenApi.isFullScreen()){
this.style.lineHeight=window.screen.height+px;
window.fullScreenApi.requestFullScreen(this)
}
else{
window.fullScreenApi.cancelFullScreen(document)
}
},true)
}
}
}
</script>
</body>
</html>
用chrome大概firefox间接运转便可。。。
</p>
Resig在2008年在其博客中介绍过HTML5的data-属性,现如今HTML5在如火如荼地推广,似乎国内的技术有些延迟,这篇博文可以在这里找到。 |
|