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 相关文章推荐
通过JQuery将DIV的滚动条滚动到指定的位置方便自动定位
May 05 Javascript
基于jquery固定于顶部的导航响应浏览器滚动条事件
Nov 02 Javascript
Html5 js实现手风琴效果
Apr 17 Javascript
详解在AngularJS的controller外部直接获取$scope
Jun 02 Javascript
解决vue.js在编写过程中出现空格不规范报错的问题
Sep 20 Javascript
Webpack之tree-starking 解析
Sep 11 Javascript
vue中使用axios post上传头像/图片并实时显示到页面的方法
Sep 27 Javascript
vue中组件通信的八种方式(值得收藏!)
Aug 09 Javascript
vue 实现通过vuex 存储值 在不同界面使用
Nov 11 Javascript
微信公众号中的JSSDK接入及invalid signature等常见错误问题分析(全面解析)
Apr 11 Javascript
vue render函数动态加载img的src路径操作
Oct 26 Javascript
vue+echarts+datav大屏数据展示及实现中国地图省市县下钻功能
Nov 16 Javascript
如何解决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
利用谷歌 Translate API制作自己的翻译脚本
2014/06/04 PHP
php实现Session存储到Redis
2015/11/11 PHP
Laravel5.7 数据库操作迁移的实现方法
2019/04/12 PHP
PHP7新增函数
2021/03/09 PHP
Javascript-Mozilla和IE中的一个函数直接量的问题
2007/01/09 Javascript
JQuery动态创建DOM、表单元素的实现代码
2011/08/09 Javascript
JS画5角星方法介绍
2013/09/17 Javascript
JQuery中$.ajax()方法参数详解及应用
2013/12/12 Javascript
js中定义一个变量并判断其是否为空的方法
2014/05/13 Javascript
JQuery给元素绑定click事件多次执行的解决方法
2014/05/29 Javascript
node.js中的console.timeEnd方法使用说明
2014/12/09 Javascript
jQuery创建自定义的选择器用以选择高度大于100的超链接实例
2015/03/18 Javascript
使用Jquery实现每日签到功能
2015/04/03 Javascript
JS模拟酷狗音乐播放器收缩折叠关闭效果代码
2015/10/29 Javascript
JavaScript的instanceof运算符学习教程
2016/06/08 Javascript
NodeJs——入门必看攻略
2016/06/27 NodeJs
JS常用知识点整理
2017/01/21 Javascript
JS实现控制图片显示大小的方法【图片等比例缩放功能】
2017/02/18 Javascript
微信小程序实现炫酷的弹出式菜单特效
2019/01/28 Javascript
浅析vue中的MVVM实现原理
2019/03/04 Javascript
利用不到200行代码写一款属于你自己的js类库
2019/07/08 Javascript
通过实例解析JavaScript常用排序算法
2020/09/02 Javascript
[02:43]中国五虎出征TI3视频
2013/08/02 DOTA
Python决策树和随机森林算法实例详解
2018/01/30 Python
使用python的pandas为你的股票绘制趋势图
2019/06/26 Python
Python OpenCV实现鼠标画框效果
2020/08/19 Python
解析python实现Lasso回归
2019/09/11 Python
python 五子棋如何获得鼠标点击坐标
2019/11/04 Python
pytorch实现对输入超过三通道的数据进行训练
2020/01/15 Python
Python实例方法、类方法、静态方法区别详解
2020/09/05 Python
详解HTML5中download属性的应用
2015/08/06 HTML / CSS
DJI大疆无人机官方商城:全球领先的无人飞行器研发和生产商
2016/12/21 全球购物
英国当代时尚和街头服饰店:18montrose
2018/12/15 全球购物
公司员工的自我评价范例
2013/11/01 职场文书
好听的队名和口号
2014/06/09 职场文书
小学美术兴趣小组活动总结
2014/07/07 职场文书