将下面的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 οnlοad=\"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"><a 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>

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

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

  1. h5网页在移动端(安卓)head里的title为空,默认显示url地址。js代码将head的title设置为空

    h5网页在移动端(安卓)head里的title为空,默认显示url地址.js代码将head的title设置为空 解决方案: document.title='\u200E' router.beforeE ...

  2. html调用js页面显示不出来了,JS代码文件调用显示乱码,直接写在html页面的里可以调用,但是单独放在js文件里不能调用...

    最近遇到了一个很奇怪的问题,就是在HTML网页代码里直接写JS代码可以正常运行的代码,使用JS文件调用就不行. var cities = [ { "name" : "北京 ...

  3. java公告栏js资源_可以文本显示的公告栏的js代码

    一个可以文本显示的公告栏,可以在多处使用,绝对不可错过! 脚本说明: 第一步:把如下代码加入head区域中 ="" !-- vari=0; =-1; =(); varHelpTex ...

  4. python退出全屏_实现网页全屏和退出全屏JS代码,多浏览器兼容

    js全屏和退出全屏代码|www.125jz.com 全屏显示 退出全屏 function requestFullScreen(element) { // 判断各种浏览器,找到正确的方法 var req ...

  5. 前端中实时显示当前时间的js代码

    纯小白,不对的地方请指正 代码: <script>var t = null;t = setTimeout(time, 1000);//開始运行function time() {clearT ...

  6. php抖音关注列表,网页PHP抖音批量取消关注JS代码

    说明 在很多时候我们抖音关注的人太多,想要批量取消但是一个一个点击太麻烦了,如何解放双手批量取消关注呢?今天分享一段JS代码,可在线批量取消关注,需电脑才能操作. 首先打开抖音创作服务平台登录:htt ...

  7. 显示当前时间的js代码

    var t = null; t = setTimeout(time, 1000);//開始运行 function time() { clearTimeout(t);//清除定时器 dt = new D ...

  8. html中只显示农历的完整代码,很全的显示阴历(农历)日期的js代码

    很全的显示阴历(农历)日期的js代码 发布于 2016-12-17 14:15:20 | 248 次阅读 | 评论: 0 | 来源: 网友投递 JavaScript客户端脚本语言Javascript ...

  9. ​Highmaps网页图表教程之绘图区显示标签显示数据标签定位

    ​Highmaps网页图表教程之绘图区显示标签显示数据标签定位 Highmaps数据标签定位 由于数据标签是和节点一一对应,所以数据标签是依据节点位置进行定位的.本节详细讲解如何对数据标签进行定位. ...

最新文章

  1. 空缺十年,百度再任命CTO!加盟十年,王海峰现集AI大权为一身
  2. 多线程学习-基础(十三)(学习参考·网摘) ArrayBlockingQueue源代碼解析(base jdk 1.8)...
  3. 链路聚合(Link Aggregation)与权重
  4. Pyhon 图片透明化
  5. wxWidgets 富文本编辑器示例
  6. java 链接mysql 产生500W数据模拟生成环境
  7. LeetCode 562. 矩阵中最长的连续1线段(DP)
  8. linux配置mysql数据库_Linux下配置mysql数据库
  9. BitMap-BitSet(JDK1.8)基本使用入门
  10. 会议室预定模拟登陆网站
  11. SQL语言入门学习,这一篇就够了
  12. android百度云和谐,视频总被百度云和谐?这个小工具帮你完美解决
  13. python str函数数字转换成字符串,Pandas将数字转换为字符串意外结果
  14. 定时器实现原理——时间轮
  15. 如何增加无人机的飞行时间和升力?
  16. python正则匹配内网IP
  17. 虚拟机ubuntu16.04下cheese 摄像头黑屏花屏问题
  18. 原生js实现搜索历史记录案例
  19. 如何运用计算机制作合同书,Word 2007 制作一份专业合同书实例WORD2007 -电脑资料...
  20. 如何解决ASP.NET网站更改后上传到IIS,看到的依然是旧版内容的问题

热门文章

  1. Windows下访问Linux文件系统
  2. 基于c++的学生档案管理系统
  3. 你们知道工控资料窝吗
  4. 马上让我们带给你视听享受吧!
  5. 人工智能 java 坦克机器人系列: 强化学习_人工智能 Java 坦克机器人系列: 强化学习...
  6. 群辉服务器更新系统教程,男人的生产力工具 篇二百四十六:新手玩转群晖NAS:一步一步教你更新群晖DSM系统...
  7. 知识付费项目怎么做?具体操作方法详解!
  8. GDB调试-从入门实践到原理
  9. df,lsblk,fdisk命令区别
  10. 360 手机助手爬虫