当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Javascript教程:PopUp对象

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript教程:PopUp对象


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 409 ::
收藏到网摘: n/a

公司要求我在一个办公系统上加上提示功能, 我研究了很久,尝试了很多种方法.使用window.open来定时提示, 可是不过多久,客户就不耐烦得说,弹出窗口太繁了.于是我想到了用CreatePopup()的方法,不过问题来了,既然是一个办公系统,要考虑到兼容性问题,不考虑到网景浏览器,我们得考虑 IE 5.0 和 IE 5.5的问题.IE 5.0不支持CreatePopup的方法,还是只能用Window.open来模拟. 于是我写了两个提示框的实现方法分别使用浏览器版本的判断而使用相应的方法. 提示框效果和MSN的提示效果一样,不过在IE 5.0是用window.open来代替CreatePopup().

window.open的MSN提示框效果要在IE 5.0以下的版本才能看到.

好了废话了那么多,我们来研究一下Popup对象

popup对象是一个无边框的窗口,它置顶于任何窗口,它必须要用脚本来控制,通过javascript我们可以控制他出现的位置,也可以往里面写内容.注意:如果固定了大小后,内容超出显示范围,不会出现滚动条,如果用户在外面点击,它就自动消失了.它使用parent 属性来访问打开它的的窗口.

1.语法

创建popup对象;

var popupobj=window.createPopup()

从创建弹出窗口的文档中访问popup对象的属性和方法:

popupobj.property | method ([parameters])

2.属性

document
popupobject.document

这个属性是创建脚本到Popup对象的唯一入口.例如

popobj.document.body.style.border=”solid 1px #000000″ 我们就可以给弹出窗口设置了一般边框.

isOpen
popupobject.isOpen
返回值:Boolean

如果弹出窗口可见,isOpen就返回True ,否则就是False.

3.方法

hide()
popupobject.hide()

提示,如果你想在弹出的窗口加上一个关闭本身的按钮,可以这么做: 假设 弹出窗口的名字是 popobj,那么就要用 parent.popobj.hide() 来关闭自己

show(left,top,width,height[,positioningElementRef])

默认left,top为0,是显示器显示的区域坐标, width,height是窗口的宽和高.