实现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 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




本文转自斯克迪亚博客园博客,原文链接:http://www.cnblogs.com/sgsoft/archive/2004/10/11/50892.html,如需转载请自行联系原作者
相关文章
|
15天前
|
JSON JavaScript 前端开发
JavaScript原生代码处理JSON的一些高频次方法合集
JavaScript原生代码处理JSON的一些高频次方法合集
|
1月前
|
存储 JavaScript 前端开发
非常实用的JavaScript一行代码(整理总结)
非常实用的JavaScript一行代码(整理总结)
30 0
|
1月前
|
数据采集 Web App开发 JavaScript
JavaScript爬虫进阶攻略:从网页采集到数据可视化
JavaScript爬虫进阶攻略:从网页采集到数据可视化
|
1月前
|
JavaScript 前端开发 测试技术
如何编写JavaScript模块化代码
如何编写JavaScript模块化代码
12 0
|
30天前
|
JSON 前端开发 JavaScript
16个重要的JavaScript代码
16个重要的JavaScript代码
30 1
|
1月前
|
JavaScript
当当网新用户注册界面——JS代码
当当网新用户注册界面——JS代码
7 0
|
1月前
|
JavaScript
当当网首页——JS代码
当当网首页——JS代码
11 1
|
1月前
|
JavaScript Java
什么?java中居然可以执行js代码了?真是不知者不怪
什么?java中居然可以执行js代码了?真是不知者不怪
13 1
|
1月前
|
JavaScript 前端开发 Python
生成X-Bogus的js代码,通过python调用生成
该文本是一个关于如何解析和执行JavaScript代码的步骤说明。主要内容包括: 1. 找到JavaScript文件的位置。 2. 下载代码并进行格式化。 3. 运行代码时会出现缺少变量错误,需要添加模拟环境的代码。 4. 指出主要的入口函数是`_0x5a8f25`,将其赋值给`window`。 5. 提供了整个JavaScript代码的长串内容。 6. 提供了一个Python脚本,用于调用这个JavaScript函数并处理返回的数据。 总结:这段文本描述了如何处理和运行一个JavaScript文件,以及使用Python来与这个脚本交互的示例。
|
1月前
|
存储 JavaScript 编译器
这款国产中文编程火了!通过文言文编译生成Python、JS、Ruby代码!
这款国产中文编程火了!通过文言文编译生成Python、JS、Ruby代码!