实现HMTL网页的全屏幕显示或模态显示

原创 2005年02月26日 22:55:00

将下面的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 onload=/"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


用Html5 or JS实现点击一个按钮达到浏览器全屏效果

点击一个按钮要实现按F11全屏的效果。 在HTML5中,W3C制定了关于全屏的API,就可以实现全屏幕的效果 项目中需要将后台浏览器的窗口全屏,也就是我们点击一个按钮要实现按F1...
  • English0523
  • English0523
  • 2016年08月11日 13:42
  • 2630

如何使用js把网页适配为一屏的几个技巧

最近看到一篇关于网页适配的经典文章,有兴趣的可以点开看看。其主要介绍的是pc页面的适配问题,个人觉得是前端开发者必须面临的问题。下面我仿这个例子做了自己的一个demo。注意:下面的例子,其实就是我们以...
  • liangklfang
  • liangklfang
  • 2016年11月08日 17:51
  • 1724

java 实现显示屏上字符串滚动显示的效果

今天路过一家商店看到滚动的显示屏,就做了这个很简单有好玩的程序,用java实现字符串滚动显示。O(∩_∩)O 下面是源代码: package main.slidetext; import java...
  • mg2flyingff
  • mg2flyingff
  • 2015年08月13日 21:52
  • 2987

1602液晶全屏幕显示0-9

  • 2011年08月08日 21:03
  • 5KB
  • 下载

popupwindow全屏幕显示被状态栏挡住如何解决+Android获取状态栏高度

转载出处:  http://blog.csdn.net/jackuhan/article/details/48369421 这是我在开发app中的筛选需求,使...
  • Working_Harder
  • Working_Harder
  • 2016年02月22日 17:08
  • 2198

C#145全屏幕显示窗体 源代码

  • 2016年12月17日 18:24
  • 46KB
  • 下载

全屏幕显示窗体,正常显示窗体,C#源代码this.FormBorderStyle =System.Windows.Forms.FormBorderStyle.None;this.WindowState = FormWindowState.Maximized;

  • 2009年01月21日 15:06
  • 33KB
  • 下载

altools.u32 课件—全屏幕显示库

  • 2012年04月23日 18:40
  • 51KB
  • 下载

popupwindow全屏幕显示被状态栏挡住如何解决+Android获取状态栏高度

转自:http://blog.csdn.net/jackuhan/article/details/48369421 这是我在开发淘粉吧app中,筛选需求,使用popupwindow显示筛选p...
  • huanglei201502
  • huanglei201502
  • 2015年12月08日 18:36
  • 1777

popupwindow全屏幕显示被状态栏挡住如何解决+Android获取状态栏高度

这是我在开发淘粉吧app中,筛选需求,使用popupwindow显示筛选panel,在我的Android4.2系统中显示效果,popupwindow被状态栏statusBar挡住。 需求中...
  • jackuhan
  • jackuhan
  • 2015年09月11日 11:51
  • 11402
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:实现HMTL网页的全屏幕显示或模态显示
举报原因:
原因补充:

(最多只允许输入30个字)