您的位置:首页 > Web前端 > HTML

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

2005-02-26 22:55 351 查看
将下面的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"><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>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐