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

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

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



//简化版本的函数,只适合于IE5.0,Windows XP以上环境
function modelScreen(strURI,X,Y,width,height){
    fullWindow 
= window.open(strURI ,"full","width=" + (width) + ",height=" + (height+1+ ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");            
    fullWindow.moveTo(X,Y);
    fullWindow.focus();
}

/*
下面的函数适合于所有主流浏览器和操作系统

参数说明:
windowWith :窗口宽度
windowHeight:窗口高度
windowX:     窗口起点X
windowY:     窗口起点Y
*/

function gfFullScreen(strURI){
    
var strAppVer = navigator.appVersion;
    
var strAppNM  = navigator.appName;
    
var intPos    = strAppVer.indexOf("MSIE",0);
    
    
var windowWith=screen.availWidth/2;
    
var windowHeight=screen.availHeight/2;
    
var windowX=20;
    
var windowY=20

    
if(strAppVer.indexOf("Win")>=0){ //OS--Windows
        if(strAppNM.indexOf("Microsoft")>=0){ //Browser--InternetExplorer
            if (strAppNM == "Microsoft Internet Explorer" && parseInt(strAppVer)>=4){ //IEversion more 4
                if(parseInt(strAppVer.slice(intPos+5,intPos+6))>=6){
                    
if(parseInt(strAppVer.indexOf("Windows NT 5.1",0)) > 0){ //WindowsXP
                        fullWindow = window.open(strURI ,"full","width=" + (windowWith) + ",height=" + (windowHeight+1+ ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
                        
//fullWindow.moveTo(-5,-32);//全屏时的参数
                        fullWindow.moveTo(windowX,windowY);
                        
                    
//    window.location.HREF="/sgsoft";
                        fullWindow.focus();
                    }
else//Not WindowsXP
                        fullWindow = window.open(strURI ,"full","width=" + (windowWith) + ",height=" + (windowHeight+1+ ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
                        
//fullWindow.moveTo(-5,-24);//全屏时的参数
                        fullWindow.moveTo(windowX,windowY);                        
                        
//window.location.HREF="/sgsoft";
                        fullWindow.focus();
                    }
                }
else{
                    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");
                    
//fullWindow.resizeTo(Math.ceil(windowWith+3),Math.ceil(windowHeight+1));
                    fullWindow.resizeTo(Math.ceil(windowWith+3),Math.ceil(windowHeight+1));
                    
//fullWindow.moveTo(0,0);//全屏时的参数
                    fullWindow.moveTo(windowX,windowY);
                    
                    fullWindow.document.open(
"text/html""replace");
                    fullWindow.document.write(
"<html><style type='text/css'>/n");
                    fullWindow.document.write(
"body{ border: 1px solid #000000; overflow: hidden; margin: 0pt;}");
                    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);}");
                    fullWindow.document.write(
"</style>/n");
                    fullWindow.document.write(
"<body onload=/"top.document.location.replace('"+strURI+"')/" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 scroll='no'>");
                    fullWindow.document.write(
"<div ID='stillloadingDiv'></div>");
                    fullWindow.document.write(
"</body></html>");
                    fullWindow.document.close();
                    
//window.location.HREF="/sgsoft";
                    fullWindow.focus();
                }
            }
else//IEversion under 4
                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);
                
//window.location.HREF="/sgsoft";
            }
        }
else if(strAppNM.indexOf("Netscape")>=0){ //Browser--NetscapeNavigator
            //fullWindow = window.open("","full","scrollbars=0,resizable=0,width=" + (windowWith-12) +",height=" + (windowHeight-30));
            fullWindow = window.open("","full","scrollbars=0,resizable=0,outerWidth=" + windowWith +",outerheight=" + windowHeight +",top=0,left=0");
            fullWindow.moveBy(
0,-10);
            fullWindow.location.href 
= strURI;
            
//window.location.HREF="/sgsoft";
        }else//Browser-- 3rdParty
            location.replace("alert.html");
            
//window.location.HREF="/sgsoft";
        }
    }
else if(strAppVer.indexOf("Mac")>=0){ //OS-Machintosh
        if(strAppVer.indexOf("Safari")>=0){ //Brower--Safari
            fullWindow=window.open("","full","scrollbars=0,resizable=0,width=" + (windowWith) +",height=" + (windowHeight-20));
            
//fullWindow.moveTo(0,0);//全屏时的参数
            fullWindow.moveTo(windowX,windowY);
            
            fullWindow.location.href
=strURI;
            
//window.location.HREF="/sgsoft";
        }else{
            
if(strAppNM.indexOf("Microsoft")>=0){ //Browser--InternetExplorer
                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");
                fullWindow.resizeTo(windowWith,windowHeight);
                
//window.location.HREF="/sgsoft";
            }else if(strAppNM.indexOf("Netscape")>=0){ //Browser--NetscapeNavigator
                fullWindow=window.open("","full","scrollbars=0,resizable=0,width=" + (windowWith-12+",height=" + (windowHeight-30));
                
//fullWindow.moveTo(0,0);
                fullWindow.moveTo(windowX,windowY);
                
                fullWindow.location.href
=strURI;
                
//window.location.HREF="/sgsoft";
            }else//Browser-- 3rdParty
                location.replace("alert.html");
                
//window.location.HREF="/sgsoft";
            }
        }
    }
else{
        location.replace(
"alert.html");
        
//window.location.HREF="/sgsoft";
    }
}


 


在HTML网页中使用它:

 

<html>
    
<head>
        
<title>LifeWithDVD</title>
        
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
        
<script type="text/javascript" src="mail_fullscreen.js"></script>
    
</head>
    
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
        text
="#ffffff" link="#ffffff" vlink="#ffffff" alink="#ffffff">
        
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="90%">
            
<tr align="center" valign="middle">
                
<td height="579" colspan="2"><br>
                    
<br>
                    
<br>
                    
<table width="135" height="135" border="0" align="center" cellpadding="0" cellspacing="0">
                        
<tr>
                            
<td width="135" height="135" colspan="2" align="center" valign="top">
                                
<table width="135" height="135" border="0" align="center" cellpadding="0" cellspacing="0">
                                    
<tr>
                                        
<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>
                                    
</tr>
                                
</table>
                            
</td>
                        
</tr>
                    
</table>
                
</td>
            
</tr>
        
</table>
    
</body>
</html>


相关文章推荐

1602液晶全屏幕显示0-9

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

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

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

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

转载出处:  http://blog.csdn.net/jackuhan/article/details/48369421 这是我在开发app中的筛选需求,使...

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

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

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

转自:http://blog.csdn.net/jackuhan/article/details/48369421 这是我在开发淘粉吧app中,筛选需求,使用popupwindow显示筛选p...

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

这是我在开发淘粉吧app中,筛选需求,使用popupwindow显示筛选panel,在我的Android4.2系统中显示效果,popupwindow被状态栏statusBar挡住。 需求中...
  • jackuhan
  • jackuhan
  • 2015年09月11日 11:51
  • 10118

实现自定义view(2):仿Android QQ多屏幕显示ListView的效果

转载请注明出处。博客地址:http://blog.csdn.net/mylzc 本文在《仿 UC,墨迹天气左右拖动 多屏幕显示效果》的基础上对代码进行修改,模仿Android QQ主界面的分屏Lis...
  • mylzc
  • mylzc
  • 2011年09月19日 07:26
  • 15090

iOS 开发 高级:通过AirServer使用AirPlay镜像并实现多屏幕显示控制

AirPlay是iOS中一个很酷的功能,通过Wi-Fi连接支持AirPlay的设备,然后使用镜像功能就能在其他设备显示内容,播放声音。有很多大型的游戏都支持AirPlay,这样比如连接电视时,那么iP...

iOS 开发 高级:通过AirServer使用AirPlay镜像并实现多屏幕显示控制

airplay Mac iPhone IOS App AirPlay是iOS中一个很酷的功能,通过Wi-Fi连接支持AirPlay的设备,然后使用镜像功能就能在其他设备显示内容,播放声音。有...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:实现HMTL网页的全屏幕显示或模态显示
举报原因:
原因补充:

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