JS插件overlib用法实例详解


Posted in Javascript onDecember 26, 2015

本文实例讲述了overlib用法。分享给大家供大家参考,具体如下:

overLIB 是一个生成提示框与弹出菜单等页面效果的一段非常优秀的JS代码。

它可以简单的通过设置一些参数或命令来改变弹出页面的款式、皮肤与形状,不但如此,它还提供了非常简单的扩展功能,来足客户的不同需求。

overLIB 使用非常的简单。

一、在<head></head> 标签内添加:

<script type="text/javascript" src="overlib.js"><!-- overLIB (c) Erik Bosrup --></script>

二、在<body></body>标签内添加:
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
4.10以上的版本可省略此步

三、生成两种不同款式(popup与sticky)的弹出页面

<a href="javascript:void(0);" onmouseover="return overlib('这是一个popup.');" onmouseout="return nd();">popup示例</a>
<a href="javascript:void(0);" onmouseover="return overlib('这是一个sticky',STICKY, MOUSEOFF);" onmouseout="return nd();">stick示例 </a>

四、 命令与参数

popup

Attribute Name Type Required Default Description
text string Yes n/a the text/html to display in the popup window
trigger string No onMouseOver What is used to trigger the popup window. Can be one of onMouseOver or onClick
sticky boolean No false Makes the popup stick around until closed
caption string No n/a sets the caption to title
fgcolor string No n/a color of the inside of the popup box
bgcolor string No n/a color of the border of the popup box
textcolor string No n/a sets the color of the text inside the box
capcolor string No n/a sets color of the box's caption
closecolor string No n/a sets the color of the close text
textfont string No n/a sets the font to be used by the main text
captionfont string No n/a sets the font of the caption
closefont string No n/a sets the font for the "Close" text
textsize string No n/a sets the size of the main text's font
captionsize string No n/a sets the size of the caption's font
closesize string No n/a sets the size of the "Close" text's font
width integer No n/a sets the width of the box
height integer No n/a sets the height of the box
left boolean No false makes the popups go to the left of the mouse
right boolean No false makes the popups go to the right of the mouse
center boolean No false makes the popups go to the center of the mouse
above boolean No false makes the popups go above the mouse. NOTE: only possible when height has been set
below boolean No false makes the popups go below the mouse
border integer No n/a makes the border of the popups thicker or thinner
offsetx integer No n/a how far away from the pointer the popup will show up, horizontally
offsety integer No n/a how far away from the pointer the popup will show up, vertically
fgbackground url to image No n/a defines a picture to use instead of color for the inside of the popup.
bgbackground url to image No n/a defines a picture to use instead of color for the border of the popup. NOTE: You will want to set bgcolor to "" or the color will show as well. NOTE: When having a Close link, Netscape will re-render the table cells, making things look incorrect
closetext string No n/a sets the "Close" text to something else
noclose boolean No n/a does not display the "Close" text on stickies with a caption
status string No n/a sets the text in the browsers status bar
autostatus boolean No n/a sets the status bar's text to the popup's text. NOTE: overrides status setting
autostatuscap string No n/a sets the status bar's text to the caption's text. NOTE: overrides status and autostatus settings
inarray integer No n/a tells overLib to read text from this index in the ol_text array, located in overlib.js. This parameter can be used instead of text
caparray integer No n/a tells overLib to read the caption from this index in the ol_caps array
capicon url No n/a displays the image given before the popup caption
snapx integer No n/a snaps the popup to an even position in a horizontal grid
snapy integer No n/a snaps the popup to an even position in a vertical grid
fixx integer No n/a locks the popups horizontal position Note: overrides all other horizontal placement
fixy integer No n/a locks the popups vertical position Note: overrides all other vertical placement
background url No n/a sets image to be used instead of table box background
padx integer,integer No n/a pads the background image with horizontal whitespace for text placement. Note: this is a two parameter command
pady integer,integer No n/a pads the background image with vertical whitespace for text placement. Note: this is a two parameter command
fullhtml boolean No n/a allows you to control the html over a background picture completely. The html code is expected in the "text" attribute
frame string No n/a controls popups in a different frame. See the overlib page for more info on this function
timeout string No n/a calls the specified javascript function and takes the return value as the text that should be displayed in the popup window
delay integer No n/a makes that popup behave like a tooltip. It will popup only after this delay in milliseconds
hauto boolean No n/a automatically determine if the popup should be to the left or right of the mouse.
vauto boolean No n/a automatically determine if the popup should be above or below the mouse.

overLIB 可以接受任意个命令和参数。格式如下:命令[,'命令参数']

<a href="javascript:void(0);" onclick="return overlib('This is a sticky with a caption. And it is centered under the mouse!', STICKY, CAPTION,
'Sticky!', CENTER);" onmouseout="nd();">Click here!</a>

五、 overlib的一些使用示例

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<scriptlanguage="JavaScript" src="overlib.js"></script><html>
<head>
<metahttp-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<ahref="#" onclick="return overlib('使用overlib的命令', CAPTION, '这是Caption命令,就是生成头部',HAUTO);"" onmouseout="return nd();">弹出测试</a>
<ahref="javascript:void(0);" onmouseover="return overlib('This is an ordinary popup.',CLOSECLICK);" onmouseout="return nd();">here</a>
<ahref="javascript:void(0);" onmouseover="return overlib('This is what we call a sticky, since I stick around (it goes away if you move the mouse OVER and then OFF the overLIB popup--or mouseover another overLIB).', STICKY, MOUSEOFF);" onmouseout="return nd();">吸附性的提示框</a>
<ahref="javascript:void(0);" onclick="return overlib('This is a sticky with a caption. And it is centered under the mouse!', STICKY, CAPTION,'Sticky!',CENTER);">含CAPTION的STICKY!</a>
<ahref="javascript:void(0);" onclick="return overlib('Setting size and posiztion!', STICKY, CAPTION,'Sticky!',HEIGHT, 100,WIDTH,120,LEFT);">指定大小与位置弹出</a>
<ahref="javascript:void(0);" onclick="return overlib('Setting size and posiztion!', STICKY, CAPTION,'Sticky!',STATUS ,'Hello');">设置状态栏</a>
</body>
</html>

六、自定义overlib。overlib有三种方式可以实现自定义。

1、我们上面用过的通过输入不同命令来实现自定义。
2、修改overlib.js中的默认值来实现自定义
3、在引用的页面指定变量来实现自定义。

overlib点击此处本站下载。

希望本文所述对大家JavaScript程序设计有所帮助。

Javascript 相关文章推荐
javascript操作html控件实例(javascript添加html)
Dec 02 Javascript
对 jQuery 中 data 方法的误解分析
Jun 18 Javascript
jQuery Validate初步体验(一)
Dec 12 Javascript
js实现拖拽效果(构造函数)
Dec 14 Javascript
javascript从定义到执行 你不知道的那些事
Jan 04 Javascript
JS与Ajax Get和Post在使用上的区别实例详解
Jun 08 Javascript
Vue.js项目部署到服务器的详细步骤
Jul 17 Javascript
在webstorm开发微信小程序之使用阿里自定义字体图标的方法
Nov 15 Javascript
layui使用表格渲染获取行数据的例子
Sep 13 Javascript
js实现文章目录索引导航(table of content)
May 10 Javascript
基于js实现数组相邻元素上移下移
May 19 Javascript
vue中控制mock在开发环境使用,在生产环境禁用方式
Apr 06 Vue.js
如何解决easyui自定义标签 datagrid edit combobox 手动输入保存不上
Dec 26 #Javascript
认识Knockout及如何使用Knockout绑定上下文
Dec 25 #Javascript
详解Document.Cookie
Dec 25 #Javascript
不得不分享的JavaScript常用方法函数集(下)
Dec 25 #Javascript
JQuery datepicker 用法详解
Dec 25 #Javascript
一道JS前端闭包面试题解析
Dec 25 #Javascript
干货分享:让你分分钟学会javascript闭包
Dec 25 #Javascript
You might like
php将数据库中所有内容生成静态html文档的代码
2010/04/12 PHP
php 删除一个数组中的某个值.兼容多维数组!
2012/02/18 PHP
PHP把网页保存为word文件的三种方法
2014/04/01 PHP
php通过数组实现多条件查询实现方法(字符串分割)
2014/05/06 PHP
PHP 二级子目录(后台目录)设置二级域名
2017/03/02 PHP
从Ajax到JQuery Ajax学习
2007/02/14 Javascript
javascript radio 联动效果
2009/03/04 Javascript
Lazy Load 延迟加载图片的 jQuery 插件
2010/02/06 Javascript
javascript textarea光标定位方法(兼容IE和FF)
2011/03/12 Javascript
使用JS取得焦点(focus)元素代码
2014/03/22 Javascript
介绍JavaScript中Math.abs()方法的使用
2015/06/14 Javascript
JS检测移动端横竖屏的代码
2016/05/30 Javascript
JavaScript监听手机物理返回键的两种解决方法
2017/08/14 Javascript
浅谈Node.js CVE-2017-14849 漏洞分析(详细步骤)
2017/11/10 Javascript
js实现把时间戳转换为yyyy-MM-dd hh:mm 格式(es6语法)
2017/12/28 Javascript
javascript的惯性运动实现代码实例
2019/09/07 Javascript
JavaScript冒泡算法原理与实现方法深入理解
2020/06/04 Javascript
浅谈vue在html中出现{{}}的原因及解决方式
2020/11/16 Javascript
[02:12]Dota 2 推出全新英雄—— 电炎绝手
2019/08/23 DOTA
python发送邮件示例(支持中文邮件标题)
2014/02/16 Python
基于Python实现的扫雷游戏实例代码
2014/08/01 Python
Python解惑之整数比较详解
2017/04/24 Python
Python编程实现的简单神经网络算法示例
2018/01/26 Python
python实现彩票系统
2020/06/28 Python
谈一谈基于python的面向对象编程基础
2019/05/21 Python
使用python-pptx包批量修改ppt格式的实现
2020/02/14 Python
Python Scrapy框架:通用爬虫之CrawlSpider用法简单示例
2020/04/11 Python
CSS3教程(5):网页背景图片
2009/04/02 HTML / CSS
HTML5页面中尝试调起APP功能
2017/09/12 HTML / CSS
新西兰Bookabach:查找全球度假屋
2020/12/03 全球购物
飞利信loadrunner和软件测试笔试题
2012/09/22 面试题
汽车专业学生自我评价
2014/01/19 职场文书
写给老婆的检讨书
2014/02/21 职场文书
党的生日活动方案
2014/08/15 职场文书
这样写python注释让代码更加的优雅
2021/06/02 Python
MySQL修炼之联结与集合浅析
2021/10/05 MySQL