javascript全屏幕显示的问题


返回某个固定页面:
function bk(strUrl)
{
window.location.href=strUrl
}

 

bk("A.jsp")

 


打开页面就全屏显示
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (this.name!='fullscreen'){
  window.open(location.href,'fullscreen','fullscreen,scrollbars')
}
//  End -->
</script>
<a href="JavaScript:window.close(self)">返回正常效果显示</a>
<script LANGUAGE="JavaScript">
<!--

 

window.open ("URL(如http://www.webjx.com)", "(窗口名称)123", "height=170, width=300, toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no, top=100") ;

 

//-->
</script>

 

注:
url代表弹出窗口的地址
height代表弹出窗口的高度
width代表弹出窗口的宽度
toolbar代表工具栏,no表示没有工具栏,yes为有工具栏
menubar代表菜单栏,no表示不显示菜单,用户也可以用yes
scrollbars代表滚动条,no表示没有滚动条,yes为有滚动条,也可以用auto
resizable代表是否可以缩放弹出窗口
location代表地址栏
status代表关态栏
top代表窗口距浏览器上部的距离

 


JavaScript:完全容错和浏览器自动最大化  
 
错误代码的即时处理
我们编制的JavaScript代码有时会由于我们的疏忽而存在一些错误,以至于用户
浏览时会弹出令人生厌的错误提示框架,如何处理这种情况呢?下面介绍两种常
见方法:

 


(1) 完全容错

 

即用户浏览含有错误代码的页面时,忽视所有的错误。代码如下:
;

 

〈script〉

 

function killerr() {

 

return true

 

}

 

window.onerror=killerr

 

〈/script〉

 

它虽然能掩盖错误,避免弹出错误提示框,但程序仍未正确执行,下面介绍另一
处理方法。

 

(2) 反馈错误信息

 

即当出现错误代码时,自动弹出我们预先设计好的反馈窗口,目的是用户只需简
单地按一下鼠标就可以把反馈信息发到你指定的信箱,当然反馈窗口的内容我们
可以任意修改设计。代码如下:

 

〈script〉

 

function errorinfo()

 

{

 

errorwin=window.open(″ ″,″ ″,″width=20,height=120″)

 

errorwin.document.write(′〈title〉脚本错误报告〈/title〉〈center〉该页
面发现了脚本运行错误,请〈a href=″mailto:lhy@cenpok.net″〉通知〈/a〉
管理员。〈br〉〈form〉〈input type=″button″ value=″关闭窗口″ onCli
ck=″window.close()″〉〈/form〉〈/center〉′)

 

errorwin.document.close()

 

errorwin.document.bgColor=″#ffffff″

 

return true

 

}

 

window.onerror=errorinfo

 

〈/script〉

 

优化浏览窗口

 

使用这段代码,当用户打开你的页面时,浏览器窗口会自动扩展到最大可利用空间
(非全屏),岂不是很专业?

 

以下代码放在〈head〉〈/head〉之间:

 

〈script language=″JavaScript″〉

 

〈!--function winfix() {

 

if (document.layers) {

 

width=screen.availWidth-10;

 

height=screen.availHeight-20;

 

} else {

 

var width=screen.availWidth-2;

 

var height=screen.availHeight;

 

}

 

self.resizeTo(width, height);

 

self.moveTo(0, 0);

 

}

 

//--〉

 

〈/script〉

 

以下代码放在〈body〉Tag里:

 

〈body onload=″winfix()″〉
 
 

 


<script language="javascript">
//Resize_Window
if ((screen.width == 1024) && (screen.height == 768)){
Resize_WindowX = 1024;
Resize_WindowY = 768;
self.resizeTo(Resize_WindowX,Resize_WindowY);//Resize_WindowEnd
}
else  ((screen.width > 1024) && (screen.height > 1000)){
document.body.clientWidth = 1280;
document.body.clientHeight = 1024;
self.resizeTo(document.body.clientWidth,document.body.clientHeight);//Resize_WindowEnd
}
document.body.clientWidth; document.body.clientHeight

 

</script>

 

<script language="javascript">
<!-- Begin
if ((screen.width == 640) && (screen.height == 480)){
self.location.href='640*480.htm'
}
else if ((screen.width == 800) && (screen.height == 600)){
self.location.href='800*600.htm'
}
else if ((screen.width == 1024) && (screen.height == 768)){
self.location.href='1024*768.htm'
}
else {self.location.href='else.htm'
}
// End -->
</script>

 


  用window.openr打开的子父窗口之间的操作跟框架的是不一样的,子窗口和父窗口之间有opener来联系。而源窗口要访问子窗口要通过其句柄来操作。以下小例子希望能帮助新手更了解他们的操作。

 

test.htm  

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>子父窗口的操作</title>
</head>
<body>
<script>
var win=null;
function op(){
win=window.open("about:blank","win","width=200,height=200");
win.document.write("<input type='button' value='关闭父窗口' onclick='window.opener.opener=null;window.opener.close()'>");
win.document.write("<input type='button' value='刷新你窗口' onclick='window.opener.location.reload()'>");
}
</script>
<input onclick="op()" value="打开窗口" type="button"><input type="button" value="最小化" onclick="if(win&&win.open&&!win.closed){win.resizeTo(0,0);win.moveTo(0,window.screen.width);}else alert('还没有打开窗口或已经关闭')"><input type="button" value="最大化" onclick="if(win&&win.open&&!win.closed){win.moveTo(-4,-4);win.resizeTo(screen.availWidth+8,screen.availHeight+8);}else alert('还没有打开窗口或已经关闭');"><input type=button value="关闭子窗口" onclick="if(win&&win.open&&!win.closed){win.opener=null;win.close()}else alert('还没有打开窗口或已关闭')"><input type=button value="刷新子窗口" onclick="if(win&&win.open&&!win.closed){win.location.reload();win.focus()}else alert('窗口还没有打开或已关闭')"><input type="button" value="看子窗口的大小" onclick="if(win&&win.open&&!win.closed){alert(win.document.body.clientWidth+'*'+win.document.body.clientHeight);win.focus();}else{alert('还没有打开窗口或者已关闭')};">
</body>
</html>

 


网页显示一定时间自动关闭

 


<script id=clientEventHandlersJS language=javascript>
 window.opener = null;
</script>

 

<body bgcolor="#fef4d9" onLoad="setTimeout(window.close, 5000)">

 


<html>
<head
<title>123</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
<!--
function omiga_window(){
window.open("full_window.htm","","fullscreen,scrollbars")
}
//-->
</script>
</head>

 

<body onload="omiga_window()" onblur="focus();closes.Click();" scroll="no">
<object id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</object>
<p> </p>
<p> </p>

 

全屏!

 

</body>
</html>

 


<script language=″JavaScript″〉

 

〈!--function winfix() {

 

if (document.layers) {

 

width=screen.availWidth-10;

 

height=screen.availHeight-20;

 

} else {

 

var width=screen.availWidth-2;

 

var height=screen.availHeight;

 

}

 

self.resizeTo(width, height);

 

self.moveTo(0, 0);

 

}

 

//--〉

 

〈/script〉

 

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3