无边框全屏窗口之二

简介:

http://www.dynamicdrive.com/dynamicindex8/chromeless.htm  ,Gabriel Suchowolski 公布了它的3.5版本无边框窗口代码。
但是,该版本只能在Win2000  和XP上使用,win 2003 并不支持,且IE6+SP1下只能全屏无边框。

但该技术仍然值得研究,目前来讲,要实现IE的无边框网页,仍然有大量限制。比较可行的是

http://www.cnblogs.com/sgsoft/archive/2004/10/13/51679.aspx

所展示的技术。
下面我们看看Gabriel Suchowolski 的代码:
chromeless_35.js

None.gif /*
None.gif    CHROMELESS WINDOWS v.35.1 [ 8.1K ]
None.gif    Licensed under GNU LGPL (www.gnu.org)
None.gif
None.gif    (c) Gabriel Suchowolski,2000 >> www.microbians.com
None.gif    Thanks to Gustavo Ponce >> www.urbanlove.org (resize addon)
None.gif        This script featured on Dynamic Drive (http://www.dynamicdrive.com)
None.gif
*/
None.gif
None.gif function chromeless(u,n,W,H,X,Y,cU,cO,cL,mU,mO,xU,xO,rU,rO,tH,tW,wB,wBs,wBG,wBGs,wNS,fSO,brd,max,min,res,tsz){
None.gif     var c=(document.all&&navigator.userAgent.indexOf("Win")!=-1)?1:0
None.gif     var v=navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE ")+5,navigator.appVersion.indexOf("MSIE ")+8)
None.gif    min=(v>=5.5?min: false);
None.gif     var w=window.screen.width;  var h=window.screen.height
None.gif     var W=W||w; W=( typeof(W)=='string'?Math.ceil(parseInt(W)*w/100):W); W+=(brd*2+2)*c
None.gif     var H=H||h; H=( typeof(H)=='string'?Math.ceil(parseInt(H)*h/100):H); H+=(tsz+brd+2)*c
None.gif     var X=X||Math.ceil((w-W)/2)
None.gif     var Y=Y||Math.ceil((h-H)/2)
None.gif     var s=",width="+W+",height="+H
None.gif
None.gif     if(c){
None.gif         var cTIT='\n'+
None.gif        '<html><head><META HTTP-EQUIV="imagetoolbar" CONTENT="no">\n'+
None.gif        '<script>\n'+
None.gif        ' var IcU= new Image();IcU.src="'+cU+'"; var IcO= new Image();IcO.src="'+cO+'"; var IcL= new Image();IcL.src="'+cL+'"; var IxU= new Image();IxU.src="'+xU+'"; var IxO= new Image();IxO.src="'+xO+'"; var IrU= new Image();IrU.src="'+rU+'"; var IrO= new Image();IrO.src="'+rO+'"; var ImU= new Image();ImU.src="'+mU+'"; var ImO= new Image();ImO.src="'+mO+'"\n'+
None.gif        'document.onmousemove=document.onselectstart=document.ondragstart=document.oncontextmenu= new Function("wMOV();return false");\n'+
None.gif        'b=-1\n'+
None.gif        'wLOA= function(){ if(top.ok&&document.body){'+(min?'bMIN.style.visibility="visible";':'')+'bLOA.style.visibility="hidden";wRSZ()} else setTimeout("wLOA()",500)};wLOA()\n'+
None.gif        'wRSZ= function(){ var dw=document.body.clientWidth;bCLO.style.pixelLeft=dw-22;bMIN.style.pixelLeft=bLOA.style.pixelLeft=dw-62;bFUL.style.pixelLeft=bRES.style.pixelLeft=dw-42}\n'+
None.gif        'wMAX= function(m){top.mod=m; if(m){top.mT(0,0);top.rT('+w+','+h+');bFUL.style.visibility="hidden";bRES.style.visibility="visible"} else{top.mT(top.px,top.py);top.rT(top.sW,top.sH);bFUL.style.visibility="visible";bRES.style.visibility="hidden"}}\n'+
None.gif        'wDBL= function(){ if(!top.mod)wMAX(1); else wMAX(0)}\n'+
None.gif        'wMIN= function(){top.window.moveTo(0,-4000); if(top.opener&&!top.opener.closed){top.opener.window.focus()};top.window.blur()}\n'+
None.gif        'wMOV= function(){\n'+
None.gif        ' if(b==0){top.bCOL("'+wBG+'","'+wB+'");b=-1}\n'+
None.gif        ' if(b==2&&!top.mod){top.px=event.screenX-ofx-1;top.py=event.screenY-ofy-1;top.mT(top.px,top.py)}\n'+
None.gif        ' if(b==1){top.bCOL("'+wBGs+'","'+wBs+'");ofx=event.x;ofy=event.y;b=2}\n'+
None.gif        '}</script></head>\n'+
None.gif        '<body onresize="wRSZ()" bgcolor='+wBG+'>\n'+
None.gif        '<div style="position:absolute;left:5px;top:4px;width:2000px">'+tH+'</div>\n'+
None.gif        '<img id=bMOV style="position:absolute;left:-50px;top:-50px" '+(max?'ondblclick="wDBL()"':'')+' onmousemove="wMOV()" onmousedown="b=1;wMOV()" onmouseup="b=0;wMOV()" border=0 src="" width=2000 height=2000>\n'+
None.gif        '<img id=bFUL style="position:absolute;top:4px;left:'+(W-42)+'px;'+(max?'':'display:none')+'" src="'+xU+'" border=0 onmouseover="this.src=IxO.src" onmouseout="this.src=IxU.src" onmouseup="this.src=IxU.src" onmousedown="this.src=IxU.src" onclick="wMAX(1)">\n'+
None.gif        '<img id=bRES style="position:absolute;top:4px;left:'+(W-42)+'px;visibility:hidden" src="'+rU+'" border=0  onmouseover="this.src=IrO.src" onmouseout="this.src=IrU.src" onmouseup="this.src=IrU.src" onmousedown="this.src=IrU.src" onclick="wMAX(0)">\n'+
None.gif        '<img id=bCLO style="position:absolute;top:4px;left:'+(W-22)+'px;" src="'+cU+'" border=0  onmouseover="this.src=IcO.src" onmouseout="this.src=IcU.src" onmouseup="this.src=IcU.src" onmousedown="this.src=IcU.src" onclick="top.window.close()">\n'+
None.gif        '<img id=bLOA style="position:absolute;top:4px;left:'+(W-62)+'px;" src="'+cL+'" border=0 >\n'+
None.gif        '<img id=bMIN style="position:absolute;top:4px;left:'+(W-62)+'px;visibility:hidden" src="'+mU+'" border=0  onmouseover="this.src=ImO.src" onmouseout="this.src=ImU.src" onmouseup="this.src=ImU.src" onmousedown="this.src=ImU.src" onclick="wMIN()">\n'+
None.gif        '</body>\n'+
None.gif        '</html>'
None.gif        
None.gif        cTIT=cTIT.replace(/\ // g,"\\\/").replace(/\"/g,"\\\"").replace(/\n/g,"\\n")
None.gif

None.gif
None.gif        cRES= function(b,s){
None.gif             var tmp='\n'+
None.gif            '<html><head><META HTTP-EQUIV="imagetoolbar" CONTENT="no">\n'+
None.gif            '<script>\n'+
None.gif            'document.onmousemove=document.onselectstart=document.ondragstart=document.oncontextmenu= new Function("wMOV();return false");\n'+
None.gif            'b=-1\n'+
None.gif            'wMOV= function(){ if(!top.mod){\n'+
None.gif            ' if(b==0){top.sH=top.fH;top.sW=top.fW;b=-1}\n'+
None.gif            ' if(b==2&&(1=='+b+'||4=='+b+'||5=='+b+')){tmp=event.screenY-oH; if(top.sH+tmp>100){top.fH=top.sH+tmp}}\n'+
None.gif            ' if(b==2&&(2=='+b+'||4=='+b+')){tmp=event.screenX-oW; if(top.sW-tmp>100){top.fW=top.sW-tmp;top.px=event.screenX-ofx-1}}\n'+
None.gif            ' if(b==2&&(3=='+b+'||5=='+b+')){tmp=event.screenX-oW;top.fW=top.sW+tmp}\n'+
None.gif            ' if(b==2){setTimeout("top.rT(top.fW,top.fH);top.mT(top.px,top.py);",10)}\n'+
None.gif            ' if(b==1){ofx=event.x;oH=event.screenY;oW=event.screenX;b=2}\n'+
None.gif            '}}</script></head>\n'+
None.gif            '<body bgcolor='+wBG+'>\n'+
None.gif            '<img style="cursor:'+s+'-resize" id=bMOV style="position:absolute;left:-50px;top:-50px" onmousemove="wMOV()" onmousedown="b=1;wMOV()" onmouseup="b=0;wMOV()" border=0 src="" width=3000 height=2000>\n'+
None.gif            '</body>\n'+
None.gif            '</html>'
None.gif             return tmp.replace(/\ // g,"\\\/").replace(/\"/g,"\\\"").replace(/\n/g,"\\n")
None.gif
        }
None.gif
None.gif         var cRESd=cRES(1,'s'),cRESl=cRES(2,'w'),cRESr=cRES(3,'e'),cRESbl=cRES(4,'sw'),cRESbr=cRES(5,'se')
None.gif
None.gif         var cFRM='<HTML><HEAD><TITLE>'+tW+'</TITLE>\n'+
None.gif        '<script>\n'+
None.gif        'ok=0;mod=0;sH=fH='+(H)+';sW=fW='+(W)+';px='+(X)+';py='+(Y)+'\n'+
None.gif        'bCOL= function(c1,c2){fT.document.bgColor=n0.document.bgColor=n1.document.bgColor=n2.document.bgColor=n3.document.bgColor=n4.document.bgColor=c1;bL.document.bgColor=bT.document.bgColor=bR.document.bgColor=bB.document.bgColor=c2}\n'+
None.gif        'mTIT= function(){ if(frames.length>8){fT.document.write("'+cTIT+'");fT.document.close(); if ('+res+'){n2.document.write("'+cRESd+'");n2.document.close();n1.document.write("'+cRESr+'");n1.document.close();n0.document.write("'+cRESl+'");n0.document.close();n3.document.write("'+cRESbl+'");n3.document.close();n4.document.write("'+cRESbr+'");n4.document.close()};top.bCOL("'+wBG+'","'+wB+'")} else{setTimeout("mTIT()",20)}}\n'+
None.gif        'mT= function(x,y){top.window.moveTo(x,y)}\n'+
None.gif        'rT= function(w,h){top.window.resizeTo(w,h)}\n'+
None.gif        'top.rT(fW,fH);top.mT(px,py)\n'+
None.gif        'mTIT()\n'+
None.gif        '</script></HEAD>\n'+
None.gif        '<frameset onselectstart="return false" onload="top.ok=1" onfocus="if (top.ok&&fT&&fT.wMAX) fT.wMAX(top.mod)" border=0 framespacing=0 frameborder=0 rows="'+tsz+',100%,'+brd+'">\n'+
None.gif        '    <frame name=fT src="about:blank" scrolling=no noresize>\n'+
None.gif        '    <frameset border=0 framespacing=0 frameborder=0 cols="'+brd+',1,100%,1,'+brd+'">\n'+
None.gif        '        <frame name=n0 src="about:blank" scrolling=no noresize>\n'+
None.gif        '        <frame name=bL src="about:blank" scrolling=no noresize>\n'+
None.gif        '            <frameset border=0 framespacing=0 frameborder=0 rows="1,100%,1">\n'+
None.gif        '                <frame name=bT src="about:blank" scrolling=no noresize>\n'+
None.gif        '                <frame name=main src="'+u+'" '+fSO+'>\n'+
None.gif        '                <frame name=bB src="about:blank" scrolling=no noresize>\n'+
None.gif        '            </frameset>\n'+
None.gif        '        <frame name=bR src="about:blank" scrolling=no noresize>\n'+
None.gif        '        <frame name=n1 src="about:blank" scrolling=no noresize>\n'+
None.gif        '    </frameset>\n'+
None.gif        '    <frameset border=0 framespacing=0 frameborder=0 cols="'+brd+',100%,'+brd+'">\n'+
None.gif        '        <frame name=n3 src="about:blank" scrolling=no noresize>\n'+
None.gif        '        <frame name=n2 src="about:blank" scrolling=no noresize>\n'+
None.gif        '        <frame name=n4 src="about:blank" scrolling=no noresize>\n'+
None.gif        '    </frameset>\n'+
None.gif        '</frameset>\n'+
None.gif        '</HTML>'
None.gif
None.gif         var CWIN=window.open("",n,"fullscreen=1"+s)
None.gif        CWIN.moveTo(5000,0)
None.gif        CWIN.ft= true
None.gif        CWIN.document.write(cFRM)
None.gif        CWIN.document.close()
None.gif    }  else {
None.gif         var CWIN=window.open(u,n,wNS+s, true)
None.gif        CWIN.moveTo(X,Y)
None.gif    }
None.gif    CWIN.focus()
None.gif    CWIN.setURL= function(u) {  if ( this && ! this.closed) {  if ( this.frames.main)  this.frames.main.location.href=u;  else  this.location.href=u } }
None.gif    CWIN.closeIT= function() {  if ( this && ! this.closed)  this.close() }
None.gif     return CWIN
None.gif}                                                                               
None.gif                                                                               
None.gif
None.gif

应用的网页:

None.gif < html >
None.gif
None.gif < head >
None.gif
None.gif < script  language ="javascript"  type ="text/javascript"  src ="chromeless_35.js" ></ script >
ExpandedBlockStart.gif < script  language ="javascript" >
InBlock.gif
ExpandedSubBlockStart.gif
/*
InBlock.gifChromeless Window (v3.5)- By Gabriel Suchowolski (this credit MUST stay intact)
InBlock.gifAuthor site at http://www.microbians.com
InBlock.gifVisit http://www.dynamicdrive.com for this script
ExpandedSubBlockEnd.gif
*/

InBlock.gif
InBlock.gif
//For paramater explanations, see accompanying faq.htm file
ExpandedSubBlockStart.gif
function openIT(u,W,H,X,Y,n,b,x,m,r) {
InBlock.gif
var cU ='close.gif' //gif for close on normal state.
InBlock.gif
var cO ='close.gif' //gif for close on mouseover.
InBlock.gif
var cL ='clock.gif' //gif for loading indicator.
InBlock.gif
var mU ='minimize.gif' //gif for minimize to taskbar on normal state.
InBlock.gif
var mO ='minimize.gif' //gif for minimize to taskbar on mouseover.
InBlock.gif
var xU ='max.gif' //gif for maximize normal state.
InBlock.gif
var xO ='max.gif' //gif for maximize on mouseover.
InBlock.gif
var rU ='restore.gif' //gif for minimize on normal state.
InBlock.gif
var rO ='restore.gif' //gif for minimize on mouseover.
InBlock.gif
var tH ='<font face=verdana size=2>Chromeless Window</font>//title for the title bar in html format.
InBlock.gif
var tW ='Chromeless Window' //title for the task bar of Windows.
InBlock.gif
var wB ='#D5D5FF' //Border color.
InBlock.gif
var wBs ='#D5D5FF' //Border color on window drag.
InBlock.gif
var wBG ='#D5D5FF' //Background of the title bar.
InBlock.gif
var wBGs='#D5D5FF' //Background of the title bar on window drag.
InBlock.gif
var wNS ='toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0//Html parameters for Netscape.
InBlock.gif
var fSO ='scrolling=auto noresize' //Html parameters for main content frame.
InBlock.gif
var brd =b||5//Extra border size.
InBlock.gif
var max =x||false//Maxzimize option (true|false).
InBlock.gif
var min =m||false//Minimize to taskbar option (true|false).
InBlock.gif
var res =r||false//Resizable window (true|false).
InBlock.gif
var tsz =20//Height of title bar.
InBlock.gif
return chromeless(u,n,W,H,X,Y,cU,cO,cL,mU,mO,xU,xO,rU,rO,tH,tW,wB,wBs,wBG,wBGs,wNS,fSO,brd,max,min,res,tsz)
ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif
None.gif
</ script >
None.gif
None.gif </ head >
None.gif
None.gif < body >
None.gif
None.gif < p >< href ="#"  onclick ="mywin001=openIT('http://www.google.com',600,400,null,null,'mywin001',5,true,true,true);return false" >
None.gifOpen Google.com </ a >
None.gif
None.gif < p >< href ="#"  onclick ="mywin002=openIT('http://www.dynamicdrive.com/faqs.htm',550,600,null,null,'mywin002',5,false,false,true,'#FF8000','#FFC184');return false" >
None.gifDynamic Drive FAQs </ a >
None.gif
None.gif </ body >
None.gif
None.gif </ html >
None.gif
None.gif

在IE 6 +SP1下,他只能支持全屏无边框。希望下一个版本能够采用新的技术,实现任何情况下无边框。




本文转自斯克迪亚博客园博客,原文链接:http://www.cnblogs.com/sgsoft/archive/2004/10/13/51691.html,如需转载请自行联系原作者

相关文章
|
API C# Windows
Winform控件优化之无边框窗体及其拖动、调整大小和实现最大最小化关闭功能的自定义标题栏效果
Winform中实现无边框窗体只需要设置FormBorderStyle = FormBorderStyle.None,但是无边框下我们需要保留移动窗体、拖拽调整大小、自定义美观好看的标题栏等...
2715 0
Winform控件优化之无边框窗体及其拖动、调整大小和实现最大最小化关闭功能的自定义标题栏效果
|
C# 编解码
WPF C# 多屏情况下,实现窗体显示到指定的屏幕内
原文:WPF C# 多屏情况下,实现窗体显示到指定的屏幕内 针对于一个程序,需要在两个显示屏上显示不同的窗体,(亦或N个显示屏N个窗体),可以使用如下的方式实现。
4701 0
Qt无边框窗口拖拽和阴影
无边框窗口的实现
371 0
Qt无边框窗口拖拽和阴影
UGUI系列-鼠标移动到按钮上显示信息(Unity3D)
有时候图标不能很好的说明这个功能的解释,就需要一些说明性文字显示。就比如可以在鼠标移动到UI上面的时候显示文字。 那么如何在UGUI上,鼠标移动上去显示文字说明呢。 大家都知道,当鼠标移动到button按钮上面的时候会出现变化,主要是button这个组件在控制
|
C#
WPF 创建无边框的圆角窗口
原文:WPF 创建无边框的圆角窗口 如题所述,在WPF中要创建一个没有边框且为圆角的窗体,有如下几步工作要进行: 第一步:去掉窗体默认样式的边框 首先将窗体的背景设为透明,将允许透明的属性设置为True,...
2577 0
QT软件开发: 点击鼠标在窗口里绘制矩形(窗口透明背景)
QT软件开发: 点击鼠标在窗口里绘制矩形(窗口透明背景)
470 0
QT软件开发: 点击鼠标在窗口里绘制矩形(窗口透明背景)
Qt-网易云音乐界面实现-1 窗口隐藏拖拽移动,自定义标题栏
最近也换了公司,也换了新的工作,工资也象征性的涨了一点点,但是最近心里还是慌慌,不知道为什么,没有那种踏实感,感觉自己随时可以被抛弃的感觉。感觉自己在荒废时间,也感觉自己在浪费生命。
245 0
Qt-网易云音乐界面实现-1 窗口隐藏拖拽移动,自定义标题栏
|
API 数据安全/隐私保护
VB编程:无标题栏窗体移动和自定义鼠标样式
VB编程:无标题栏窗体移动和自定义鼠标样式
205 0
|
C#
wpf无边框窗体移动和大小调整
原文:wpf无边框窗体移动和大小调整   using System; using System.Windows; using System.
1600 0
|
C#
WPF 自定义窗口关闭按钮
原文:WPF 自定义窗口关闭按钮 关闭图标设计主要涉及主要知识点: 1、Path,通过Path来画线。当然一般水平、竖直也是可以用Rectangle/Border之类的替代      一些简单的线条图标用Path来做,还是很方便的。
1153 0