您的位置:首页 > 其它

几个常用的脚本写法

2008-10-10 08:51 579 查看
返回按钮的写法:(要求:如果是打开新窗口,则关闭窗口,否则就返回前一页或者指定页)

<input type="button" value="返回" onclick="try{if(typeof(window.opener)!='object'){location.href='WebQuery.aspx?repoid=78102';}else{window.close();}}catch(e){}" />

<input type="button" value="返回" onclick="try{if(typeof(window.opener)!='object'){history.back();}else{window.close();}}catch(e){}" />

OpenNewWindow("xxx.aspx");

OpenNewWindow("xxx.aspx",true);

//根据参数IsMax来决是否打开全屏窗口:IsMax为true打开全屏

function OpenNewWindow(strUrl, IsMax,isResize,widthPx,heightPx)

{

if (typeof(widthPx) == "undefined")

{

var widthPx=600;

}

if (typeof(lengthPx) == "undefined")

{

var heightPx=400;

}

if(typeof(isResize) == "undefined")

{

var isResize = 1;

}

if(typeof(IsMax) == "undefined")

{

var IsMax = true;

}

var strFeatures ="width="+widthPx+",height="+heightPx+",resizable="+isResize+",scrollbars=1,status=1,center=1";

newwin=window.open(strUrl,"",strFeatures)

if(IsMax)

{

if (document.all)

{

newwin.moveTo(0,0);

newwin.resizeTo(screen.width,screen.height);

newwin.outerWidth=screen.availWidth;

newwin.outerHeight=screen.availHeight;

newwin.focus();

return;

}

}

else

{

newwin.moveTo((window.screen.availWidth-widthPx)/2,(window.screen.availHeight-heightPx)/2);

newwin.resizeTo(widthPx,heightPx);

newwin.focus();

}

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