实现HMTL网页的全屏幕显示或模态显示 (JS代码)

将下面的JS保存为:mail_fullscreen.js文件

None.gif
None.gif
None.gif
// 简化版本的函数,只适合于IE5.0,Windows XP以上环境
None.gif
function  modelScreen(strURI,X,Y,width,height){
None.gif    fullWindow 
=  window.open(strURI , " full " , " width= "   +  (width)  +   " ,height= "   +  (height + 1 +   " ,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0 " );            
None.gif    fullWindow.moveTo(X,Y);
None.gif    fullWindow.focus();
None.gif}
None.gif
None.gif
/*
None.gif下面的函数适合于所有主流浏览器和操作系统
None.gif
None.gif参数说明:
None.gifwindowWith :窗口宽度
None.gifwindowHeight:窗口高度
None.gifwindowX:     窗口起点X
None.gifwindowY:     窗口起点Y
None.gif
*/
None.gif
None.gif
function  gfFullScreen(strURI){
None.gif    
var  strAppVer  =  navigator.appVersion;
None.gif    
var  strAppNM   =  navigator.appName;
None.gif    
var  intPos     =  strAppVer.indexOf( " MSIE " , 0 );
None.gif    
None.gif    
var  windowWith = screen.availWidth / 2 ;
None.gif    
var  windowHeight = screen.availHeight / 2 ;
None.gif    
var  windowX = 20 ;
None.gif    
var  windowY = 20
None.gif
None.gif    
if (strAppVer.indexOf( " Win " ) >= 0 ){  // OS--Windows
None.gif
         if (strAppNM.indexOf( " Microsoft " ) >= 0 ){  // Browser--InternetExplorer
None.gif
             if  (strAppNM  ==   " Microsoft Internet Explorer "   &&  parseInt(strAppVer) >= 4 ){  // IEversion more 4
None.gif
                 if (parseInt(strAppVer.slice(intPos + 5 ,intPos + 6 )) >= 6 ){
None.gif                    
if (parseInt(strAppVer.indexOf( " Windows NT 5.1 " , 0 ))  >   0 ){  // WindowsXP
None.gif
                        fullWindow  =  window.open(strURI , " full " , " width= "   +  (windowWith)  +   " ,height= "   +  (windowHeight + 1 +   " ,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0 " );
None.gif                        
// fullWindow.moveTo(-5,-32);//全屏时的参数
None.gif
                        fullWindow.moveTo(windowX,windowY);
None.gif                        
None.gif                    
//     window.location.HREF="/sgsoft";
None.gif
                        fullWindow.focus();
None.gif                    }
else // Not WindowsXP
None.gif
                        fullWindow  =  window.open(strURI , " full " , " width= "   +  (windowWith)  +   " ,height= "   +  (windowHeight + 1 +   " ,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0 " );
None.gif                        
// fullWindow.moveTo(-5,-24);//全屏时的参数
None.gif
                        fullWindow.moveTo(windowX,windowY);                        
None.gif                        
// window.location.HREF="/sgsoft";
None.gif
                        fullWindow.focus();
None.gif                    }
None.gif                }
else {
None.gif                    fullWindow 
=  window.open( ""  , " full " , " fullscreen=1,width= "   +  (windowWith + 3 +   " ,height= "   +  (windowHeight + 1 +   " ,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0 " );
None.gif                    
// fullWindow.resizeTo(Math.ceil(windowWith+3),Math.ceil(windowHeight+1));
None.gif
                    fullWindow.resizeTo(Math.ceil(windowWith + 3 ),Math.ceil(windowHeight + 1 ));
None.gif                    
// fullWindow.moveTo(0,0);//全屏时的参数
None.gif
                    fullWindow.moveTo(windowX,windowY);
None.gif                    
None.gif                    fullWindow.document.open(
" text/html " " replace " );
None.gif                    fullWindow.document.write(
" <html><style type='text/css'>\n " );
None.gif                    fullWindow.document.write(
" body{ border: 1px solid #000000; overflow: hidden; margin: 0pt;} " );
None.gif                    fullWindow.document.write(
" #stillloadingDiv{ position: absolute; left: 0px; top: 0px; width: 100%px; height: 19px; z-index: 1; background-color: #C0C0C0; layer-background-color: #C0C0C0; clip:rect(0,100%,19,0);} " );
None.gif                    fullWindow.document.write(
" </style>\n " );
None.gif                    fullWindow.document.write(
" <body οnlοad=\ " top.document.location.replace(' " +strURI+ " ')\ "  topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 scroll='no'> " );
None.gif                    fullWindow.document.write(
" <div ID='stillloadingDiv'></div> " );
None.gif                    fullWindow.document.write(
" </body></html> " );
None.gif                    fullWindow.document.close();
None.gif                    
// window.location.HREF="/sgsoft";
None.gif
                    fullWindow.focus();
None.gif                }
None.gif            }
else // IEversion under 4
None.gif
                fullWindow  =  window.open(strURI, " full " , " width= "   +  (windowWith + 1 +   " ,height= "   +  (windowHeight - 21 +   " ,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,left=0,top=0,screenX=0,screenY=0 " , true );
None.gif                
// window.location.HREF="/sgsoft";
None.gif
            }
None.gif        }
else   if (strAppNM.indexOf( " Netscape " ) >= 0 ){  // Browser--NetscapeNavigator
None.gif
             // fullWindow = window.open("","full","scrollbars=0,resizable=0,width=" + (windowWith-12) +",height=" + (windowHeight-30));
None.gif
            fullWindow  =  window.open( "" , " full " , " scrollbars=0,resizable=0,outerWidth= "   +  windowWith  + " ,outerheight= "   +  windowHeight  + " ,top=0,left=0 " );
None.gif            fullWindow.moveBy(
0 , - 10 );
None.gif            fullWindow.location.href 
=  strURI;
None.gif            
// window.location.HREF="/sgsoft";
None.gif
        } else // Browser-- 3rdParty
None.gif
            location.replace( " alert.html " );
None.gif            
// window.location.HREF="/sgsoft";
None.gif
        }
None.gif    }
else   if (strAppVer.indexOf( " Mac " ) >= 0 ){  // OS-Machintosh
None.gif
         if (strAppVer.indexOf( " Safari " ) >= 0 ){  // Brower--Safari
None.gif
            fullWindow = window.open( "" , " full " , " scrollbars=0,resizable=0,width= "   +  (windowWith)  + " ,height= "   +  (windowHeight - 20 ));
None.gif            
// fullWindow.moveTo(0,0);//全屏时的参数
None.gif
            fullWindow.moveTo(windowX,windowY);
None.gif            
None.gif            fullWindow.location.href
= strURI;
None.gif            
// window.location.HREF="/sgsoft";
None.gif
        } else {
None.gif            
if (strAppNM.indexOf( " Microsoft " ) >= 0 ){  // Browser--InternetExplorer
None.gif
                fullWindow  =  window.open(strURI, " full " , " alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=1,directories=0,fullscreen=1,hotkeys=1,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,z-lock=0,screenX=0,screeny=0,left=0,top=0 " );
None.gif                fullWindow.resizeTo(windowWith,windowHeight);
None.gif                
// window.location.HREF="/sgsoft";
None.gif
            } else   if (strAppNM.indexOf( " Netscape " ) >= 0 ){  // Browser--NetscapeNavigator
None.gif
                fullWindow = window.open( "" , " full " , " scrollbars=0,resizable=0,width= "   +  (windowWith - 12 + " ,height= "   +  (windowHeight - 30 ));
None.gif                
// fullWindow.moveTo(0,0);
None.gif
                fullWindow.moveTo(windowX,windowY);
None.gif                
None.gif                fullWindow.location.href
= strURI;
None.gif                
// window.location.HREF="/sgsoft";
None.gif
            } else // Browser-- 3rdParty
None.gif
                location.replace( " alert.html " );
None.gif                
// window.location.HREF="/sgsoft";
None.gif
            }
None.gif        }
None.gif    }
else {
None.gif        location.replace(
" alert.html " );
None.gif        
// window.location.HREF="/sgsoft";
None.gif
    }
None.gif}
None.gif


 


在HTML网页中使用它:

 

None.gif < html >
None.gif    
< head >
None.gif        
< title > LifeWithDVD </ title >
None.gif        
< meta  http-equiv ="Content-Type"  content ="text/html; charset=Shift_JIS" >
None.gif        
< script  type ="text/javascript"  src ="mail_fullscreen.js" ></ script >
None.gif    
</ head >
None.gif    
< body  bgcolor ="#ffffff"  leftmargin ="0"  topmargin ="0"  marginwidth ="0"  marginheight ="0"
None.gif        text
="#ffffff"  link ="#ffffff"  vlink ="#ffffff"  alink ="#ffffff" >
None.gif        
< table  width ="100%"  border ="0"  cellspacing ="0"  cellpadding ="0"  height ="90%" >
None.gif            
< tr  align ="center"  valign ="middle" >
None.gif                
< td  height ="579"  colspan ="2" >< br >
None.gif                    
< br >
None.gif                    
< br >
None.gif                    
< table  width ="135"  height ="135"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
None.gif                        
< tr >
None.gif                            
< td  width ="135"  height ="135"  colspan ="2"  align ="center"  valign ="top" >
None.gif                                
< table  width ="135"  height ="135"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
None.gif                                    
< tr >
None.gif                                        
< td  height ="135" >< href ="javascript:modelScreen('content/main.html',20,20,800,600);" >< img  src ="./image/sun.jpg"  width ="827"  height ="297"  border ="0" ></ a ></ td >
None.gif                                    
</ tr >
None.gif                                
</ table >
None.gif                            
</ td >
None.gif                        
</ tr >
None.gif                    
</ table >
None.gif                
</ td >
None.gif            
</ tr >
None.gif        
</ table >
None.gif    
</ body >
None.gif
</ html >
None.gif


 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值