网页打开自动最大化的js代码
作者:
有时候我们需要当页面打开时,自动最大化,一来方便用户浏览,而且快速将页面呈现给大家
代码1:最常用的代码,比较简单
<script language="javascript">
self.moveto(0,0)
self.resizeto(screen.availwidth,screen.availheight)
</script>
代码2:
以下代码放在<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()″>
代码3:
代码如下:
<script language="javascript">
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
</script>
<OBJECT id="max" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-
00aa003b7a11">
<PARAM name="Command" value="Maximize"></OBJECT>
<BODY onload="if(document.body.offsetWidth<screen.width)max.Click()">>
代码4:
<SCRIPT>
var mywidth
if (navigator.appName.indexOf('Netscape') != -1) {
mywidth=parseInt(window.outerWidth)-28;
//alert("ns")
}
else{
if (navigator.appName.indexOf('Microsoft') != -1) {
mywidth=document.body.clientWidth;
//alert("ie")
}
}
var ScreenOffset;
if (mywidth <= 778) {
//alert("1")
}else{
ScreenOffset = parseInt((mywidth - 778)/2);
ScreenOffset = 0;
// alert("2")
}
fwLoadMenus();
window.onresize = function (){
if (navigator.appName.indexOf('Netscape') != -1) {
mywidth=parseInt(window.outerWidth)-28;
if(self.screenLeft>0){
maximize.Click();
}
}
else{
if (navigator.appName.indexOf('Microsoft') != -1) {
mywidth=document.body.clientWidth;
if(self.screenLeft>0){
maximize.Click();
}
}
}
}
function ChangeLocation(){
var size = screen.width;
if(size!="1024"){
document.location="index_800_600.aspx";
}
}
</SCRIPT>
复制代码 代码如下:
<script language="javascript">
self.moveto(0,0)
self.resizeto(screen.availwidth,screen.availheight)
</script>
代码2:
以下代码放在<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()″>
代码3:
代码如下:
复制代码 代码如下:
<script language="javascript">
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
</script>
<OBJECT id="max" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-
00aa003b7a11">
<PARAM name="Command" value="Maximize"></OBJECT>
<BODY onload="if(document.body.offsetWidth<screen.width)max.Click()">>
代码4:
复制代码 代码如下:
<SCRIPT>
var mywidth
if (navigator.appName.indexOf('Netscape') != -1) {
mywidth=parseInt(window.outerWidth)-28;
//alert("ns")
}
else{
if (navigator.appName.indexOf('Microsoft') != -1) {
mywidth=document.body.clientWidth;
//alert("ie")
}
}
var ScreenOffset;
if (mywidth <= 778) {
//alert("1")
}else{
ScreenOffset = parseInt((mywidth - 778)/2);
ScreenOffset = 0;
// alert("2")
}
fwLoadMenus();
window.onresize = function (){
if (navigator.appName.indexOf('Netscape') != -1) {
mywidth=parseInt(window.outerWidth)-28;
if(self.screenLeft>0){
maximize.Click();
}
}
else{
if (navigator.appName.indexOf('Microsoft') != -1) {
mywidth=document.body.clientWidth;
if(self.screenLeft>0){
maximize.Click();
}
}
}
}
function ChangeLocation(){
var size = screen.width;
if(size!="1024"){
document.location="index_800_600.aspx";
}
}
</SCRIPT>