bob体育官方平台
javascript之弹出窗口居中的代码

看js事件时看到了resizeTo和moveTo两个函数及window.screen.height/window.screen.width等几个属性突然想到的这个效果,花了偶一点功夫终于写出来了,感觉挺好玩,呵呵。。。

Test

screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new windownCTRL+Mouse wheel to zoom in/out';}" onclick="if {return true;} else {window.open('" alt="" src="" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new windownCTRL+Mouse wheel to zoom in/out';}" border=0>功能:1.图片可以缩放,外框也随之变动。2.图片缩放后,居底对齐。3.鼠标滑上去,边框有虚线。结构:screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new windownCTRL+Mouse wheel to zoom in/out';}" onclick="if {return true;} else {window.open('" alt="" src="" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new windownCTRL+Mouse wheel to zoom in/out';}" border=0>源代码:

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

相册自适应写法

javascript弹出窗口居中代码

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

下面给两个弹出屏幕居中窗口的例子

复制代码 代码如下:

window.open()方式
function ShowDialog(url) {
var iWidth=300; //窗口宽度
var iHeight=200;//窗口高度
var iTop=(window.screen.height-iHeight)/2;
var iLeft=(window.screen.width-iWidth)/2;
window.open(url,"Detail","Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no,
Width="+iWidth+" ,Height="+iHeight+",top="+iTop+",left="+iLeft);
}

返回顶部