标签:
1,flash覆盖colorbox:
2,colorbox在ie中的位置和行为异常:
3,colorbox的位置和行为异常(不区分浏览器):
4,用colorbox显示外部文档时显示不正确:
5,在ie中colorbox的边框不显示:
6,尝试载入外部页面却获得”Request unsuccessful”的报错信息
7,如何通过rel属性关闭colorbox的群组功能
8,JavaScript/jQuery 在colorbox中不工作
9,在iframe外面打开colorbox
|
常用事件:
onOpen:function(){ alert(‘onOpen: colorbox is about to open‘); },
onLoad:function(){ alert(‘onLoad: colorbox has started to load the targeted content‘); },
onComplete:function(){ alert(‘onComplete: colorbox has displayed the loaded content‘); },
onCleanup:function(){ alert(‘onCleanup: colorbox has begun the close process‘); },
onClosed:function(){ alert(‘onClosed: colorbox has completely closed‘); }
colorbox常见问题
http://wxinpeng.javaeye.com/blog/737230
ColorBox是一款功能强大的轻量级jQuery Lightbox插件。ColorBox支持图片展示、图片分组、幻灯片、行内样式和iframe内容。该lightbox插件的兼容性极好,可以兼容IE7+的IE浏览器。它的特点有:
使用ColorBox需要引入jQuery和jquery.colorbox.js文件以及colorbox.css文件。
<link rel="stylesheet" href="colorbox.css" /> <script src="jquery/2.1.4/jquery.min.js"></script><script src="dist/jquery.colorbox.js"></script> |
Colorbox可以接受键值对形式的参数对象。
// Format:$(selector).colorbox({key:value, key:value, key:value});// Examples:// Image links displayed as a group$(‘a.gallery‘).colorbox({rel:‘gal‘});// Ajax$(‘a#login‘).colorbox();// Called directly, without assignment to an element:$.colorbox({href:"thankyou.html"});// Called directly with HTML$.colorbox({html:"<h1>Welcome</h1>"});// Colorbox can accept a function in place of a static value:$("a.gallery").colorbox({rel: ‘gal‘, title: function(){ var url = $(this).attr(‘href‘); return ‘<a href="‘ + url + ‘" target="_blank">Open In New Window</a>‘;}}); |
| 参数 | 默认值 | 描述 |
| transition | "elastic" | 过渡动画类型。可设置为"elastic", "fade", "none" |
| speed | 350 | 过渡动画的速度。单位毫秒 |
| href | false | 该参数用于替换锚链接,或一个无URL连接的元素,如图片,或表单按钮$("h1").colorbox({href:"welcome.html"}); |
| rel | false | 这个参数可以作为一个锚REL的替代方式。它允许用户将任何元素组合为一个组,制作图片画廊 |
| scalePhotos | true | 如果为true并且定义了maxWidth、maxHeight、innerWidth、innerHeight、width或height属性,Colorbox将缩放图片以适应这些值 |
| scrolling | true | 如果为false,Colorbox 将隐藏滚动条 |
| opacity | 0.85 | 遮罩层的透明度。值从0-1 |
| open | false | 如果为true,Colorbox会立刻打开 |
| returnFocus | true | 如果为true,当Colorbox存在元素的时候会被聚焦 |
| trapFocus | true | 如果为true,Colorbox的键盘控制导航和内容将被限制 |
| fastIframe | true | 如果为false,加载的图片会被移除,onComplete事件会被延迟直到iframe的内容加载完毕 |
| preloading | true | 运行在组中预加载前一幅和下一幅图片 |
| overlayClose | true | 如果为false,禁止点击遮罩层关闭Colorbox |
| escKey | true | 如果为false,将禁止使用“ESC”键关闭Colorbox |
| arrowKey | true | 如果为false,将禁止在组中使用前后导航箭头按钮 |
| loop | true | 如果为false,图片组将不会循环 |
| data | false | 通过ajax请求提交的GET或POST的值 |
| className | false | 为colorbox 和遮罩层添加一个给定的class名称 |
| fadeOut | 300 | 设置关闭Colorbox时fadeOut效果的速度,单位毫秒 |
| closeButton | true | Colorbox的关闭按钮 |
| 参数 | 默认值 | 描述 |
| current | "image {current} of {total}" | 图片组中图片数量。{current} 和 {total}在运行时会被替换 |
| previous | "previous" | 前一张图片按钮的显示文字 |
| next | "next" | 下一张图片按钮的显示文字 |
| close | "close" | 关闭按钮上的显示文字。“ESC”键也可以关闭Colorbox |
| xhrError | "This content failed to load." | 指定的ajax调用的内容没有被正确加载时显示的文字 |
| imgError | "This image failed to load." | 图片内容没有被加载时显示的文字 |
| 参数 | 默认值 | 描述 |
| iframe | false | 如果为true,指定的内容会被显示在iFrame中 |
| inline | false | 如果为true,当前文档的内容可以通过传入一个带jQuery选择器的href作为参数来显示内容 |
| html | false | 显示一个HTML的字符串
Hello "}); |
| photo | false | 如果为true,会强制Colorbox将一个链接显示为图片 |
| ajax | This property isn‘t actually used as Colorbox assumes all hrefs should be treated as either ajax or photos, unless one of the other content types were specified. |
1、引入jquery核心库和ColorBox脚本文件
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script src="../colorbox/jquery.colorbox.js"></script>
2、引入ColorBox样式表文件,注意引入不同皮肤的css文件将实现不同的皮肤
<link media="screen" rel="stylesheet" href="colorbox.css" />
3、html代码
<h2>弹性效果</h2> <p> <a href="../content/ohoopee1.jpg"rel="example1" title="Me and my">GroupedPhoto1</a> </p> <p> <a href="../content/ohoopee2.jpg"rel="example1" title="On the Ohoopee">Grouped Photo 2</a> </p> <p> <a href="../content/ohoopee3.jpg"rel="example1" title="On the Ohoopee">Grouped Photo 3</a> </p> <h2>淡入淡出效果</h2> <p> <a href="../content/ohoopee1.jpg"rel="example2" title="Me and my">Grouped Photo 1</a> </p> <p> <a href="../content/ohoopee2.jpg"rel="example2" title="On the">Grouped Photo 2</a> </p> <p> <a href="../content/ohoopee3.jpg"rel="example2" title="On the Ohoopee">Grouped Photo 3</a> </p> <h2>没有动画效果,高度固定(屏幕大小的75%)</h2> <p> <a href="../content/ohoopee1.jpg"rel="example3" title="Me and my">Grouped Photo 1</a> </p> <p> <a href="../content/ohoopee2.jpg"rel="example3" title="On the">Grouped Photo 2</a> </p> <p> <a href="../content/ohoopee3.jpg"rel="example3" title="On the Ohoopee">Grouped Photo 3</a> </p> <h2>自动播放</h2> <p> <a href="../content/ohoopee1.jpg"rel="example4" title="Me">Grouped Photo 1</a> </p> <p> <a href="../content/ohoopee2.jpg"rel="example4" title="On the Ohoopee">Grouped Photo 2</a> </p> <p> <a href="../content/ohoopee3.jpg"rel="example4" title="On">Grouped Photo 3</a> </p>
4、jquery初始化代码
$(document).ready(function() {
//Examples of how to assign the Colorbox event to elements
$(".group1").colorbox({
rel: ‘group1‘
});
$(".group2").colorbox({
rel: ‘group2‘,
transition: "fade"
});
$(".group3").colorbox({
rel: ‘group3‘,
transition: "none",
width: "75%",
height: "75%"
});
$(".group4").colorbox({
rel: ‘group4‘,
slideshow: true
});
$(".ajax").colorbox();
$(".youtube").colorbox({
iframe: true,
innerWidth: 640,
innerHeight: 390
});
$(".vimeo").colorbox({
iframe: true,
innerWidth: 500,
innerHeight: 409
});
$(".iframe").colorbox({
iframe: true,
width: "80%",
height: "80%"
});
$(".inline").colorbox({
inline: true,
width: "50%"
});
$(".callbacks").colorbox({
onOpen: function() {
alert(‘onOpen: colorbox is about to open‘);
},
onLoad: function() {
alert(‘onLoad: colorbox has started to load the targeted content‘);
},
onComplete: function() {
alert(‘onComplete: colorbox has displayed the loaded content‘);
},
onCleanup: function() {
alert(‘onCleanup: colorbox has begun the close process‘);
},
onClosed: function() {
alert(‘onClosed: colorbox has completely closed‘);
}
});
$(‘.non-retina‘).colorbox({
rel: ‘group5‘,
transition: ‘none‘
}) $(‘.retina‘).colorbox({
rel: ‘group5‘,
transition: ‘none‘,
retinaImage: true,
retinaUrl: true
});
//Example of preserving a JavaScript event for inline calls.
$("#click").click(function() {
$(‘#click‘).css({
"background-color": "#f00",
"color": "#fff",
"cursor": "inherit"
}).text("Open this window again and this message will still be here.");
return false;
});
});标签:
原文地址:http://www.cnblogs.com/mfc-itblog/p/5138309.html