Jquery插件Thickbox的使用总结及自定义设置

ThickBox运行需要的文件

官方下载:

Download thickbox.js or thickbox-compressed.jsThickBox.css, and the loading graphic (loadingAnimation.gif) to your local machine (or cut and paste the code from the tabs). Along with these three files, a copy of thejQuery JavaScript library is needed. For this site, and ThickBox, I am using the compressed version of jQuery.

首先在 HTML 文件的 head中导入jquery.js 和thickbox.js文件,导入 thickbox.css 文件;并且jquery.js 文件放在前面:

<script src="../Scripts/jquery-latest.pack.js" mce_src="Scripts/jquery-latest.pack.js"type="text/javascript">script> <script src="../Scripts/thickbox.js" mce_src="Scripts/thickbox.js"type="text/javascript">script> <link href="../Styles/thickbox.css" mce_href="Styles/thickbox.css"rel="stylesheet" type="text/css" />

最后你只要给元素添加 class=”thickbox” 属性就可以开始用 thickbox

实现了一张图片的弹出展示功能:

<a href="”bg.jpg”" mce_href="”bg.jpg”" class=”thickbox” ><img src="”bg.jpg”"mce_src="”bg.jpg”" alt=”图片”/>a> //只需要指定图片的class为thickbox
弹出框使用方法:
<a href="Default.aspx?keepThis=true&TB_iframe=true&height=400&width=500" title="主页"class="thickbox" a> <input onclick="
   
   
    
    /bannedUserList!unBannedUserList?height=400&width=800&inlineId=myOnPageContent"
   
    title="弹出层" class="thickbox" type="button"value="Ban Another" /> //内嵌内容 <input alt="#TB_inline?height=300&width=400&inlineId=myOnPageContent" title="标题" class="thickbox" type="button"value="Show" /> <a href="#TB_inline?height=155&width=300&inlineId=hiddenModalContent&modal=true"class="thickbox">显示隐藏内容a> //遮罩层 URL后面加?KeepThis=true&TB_iframe=true&height=400&width=600 参数字符串中加 modal=true ?KeepThis=true&TB_iframe=true&height=400&width=600&modal=true 这样当关闭ThickBox时会调用ThickBox iframe (self.parent.tb_remove())内部的一个tb_remove()函数 所有其他参数字符都必须在TB_iframe 参数之前。URL中所有"TB" 之后的将被移除。 <a href="index.html?keepThis=true&TB_iframe=true&height=250&width=400" title="标题" class="thickbox">打开一个页面a> <ahref="index.html?keepThis=true&TB_iframe=true&height=300&width=500" title="标题"class="thickbox">打开一个页面a> <a href="index.html?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=200&width=300&modal=true" title="标题"class="thickbox">打开一个页面a>

 

自定义设置:

1、弹出窗口(div)右上角的关闭按钮为显示为"close or esc key",而不是中文的; 如果想把它变成[X]或"关闭"应该怎么来办呢?

将thickbox.js文件打开,查找关键字"or esc key",将其删除,并将前面的close更改为[X]或"关闭",然后把文件另存为UTF-8格式,如果不保存为UTF-8的话,将会出现乱码。
2、thickbox 弹出层的遮住层透明度修改

打开thickbox.css查找.TB_overlayBG 进行更改

.TB_overlayBG { background-color:#000filter:alpha(opacity=75)-moz-opacity0.75opacity0.75; }

3、关闭层:如果我们需要自己添加一个关闭按钮或者图片可以使用:

οnclick="self.parent.tb_remove();"

4、关闭层刷新父页面,修改关闭方法 :

function tb_remove() { $("#TB_imageOff").unbind("click"); $("#TB_closeWindowButton").unbind("click"); $("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();}); $("#TB_load").remove(); if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 $("body","html").css({height: "auto", width: "auto"}); $("html").css("overflow",""); } document.onkeydown = ""; document.onkeyup = ""; //刷新父页面,未指定 window.location.reload(); return false; }

5、thickbox插件默认情况是点击灰色的遮罩层就会关闭取消

把两个$("#TB_overlay").click(tb_remove);去掉就可以取消掉

6、updatepanel回发后thickbox失效的解决方法

只需把以下代码粘贴至页面中就OK了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值