jquery.sobox 经典版弹窗控件

时间:2024-09-11 10:05:02

sobox 是一款非常实用的,基于 jQuery 的弹窗控件。
功能非常完整,而代码量又非常少(压缩完仅8k不到)的一款弹窗控件,
如果你熟悉ext的弹窗控件,那么sobox的使用对你来说应该是愉悦而完全没有压力。

效果预览

引入sobox文件

  1. <link type="text/css" rel="stylesheet" media="all" href="style.css" />
  2. <script type="text/javascript" src="jquery1.9.1.min.js"></script>
  3. <script type="text/javascript" src="jquery.sobox.js"></script>
复制

使用方法

  1. $('.a-tip').click(function () {
  2. $.sobox.tip({
  3. content: '爱看不看,上面提示一下~'
  4. });
  5. return false;
  6. });
复制

sobox 基本参数

  1. //通用方法
  2. $.sobox.pop({
  3. /* 弹出类型及类型参数 */
  4. type : 'content', // 弹窗内容模式:'content','target','ajax','iframe',每个模式分别对应每个参量
  5. target : null, // target方式,target目标,如 '.detail','#contbox'
  6. content : null, // content方式,支持html
  7. iframe : null, // iframe方式,值为iframe目标页链接,如:http:// www.baidu.com/
  8. ajax:{url:null,data:null,callback:function(){}}, // ajax事件
  9. /* 位置信息 */
  10. posType:'center', // 'center,win,doc,tc,bc' 位置类型,居中 / 距window顶部 / 距离doucment顶部定 / top水平居中 / bottom水平居中,默认居中
  11. pos:[0,0], // [x,y] 距离document左上角坐标,set模式使用
  12. offset:[0,0], // [x,y] 弹窗相对本来设定位置偏移量,center模式只改变y轴
  13. /* 自定义参数 */
  14. cls : null, // 添加自定义类名
  15. width:360,height:null, // 宽高属性,iframe模式下,height为iframe高度
  16. defaultShow:true, // 直接显示pop
  17. visibility:true, // 默认pop执行后显示(用于部分复杂处理场景)
  18. title : '提示', // 默认标题
  19. showTitle:true, // 标题栏隐藏:默认显示
  20. showMask : true, // 显示遮罩
  21. drag :true, // 是否可拖动
  22. maskClick : true, // 点击背景关闭内容
  23. btn : [], // {cls:,text'确定',link:,removePop: true,callback:}
  24. /* 返回事件 */
  25. beforePop:function(){}, // 弹窗打开之前callback事件
  26. onPop: function(){}, // 页面打开callback事件
  27. closePop: function(){} // 点击标题关闭按钮返回事件
  28. });
  29. btn参数说明:
  30. 默认每个btn元素由一个.a-sopop-btn 的a元素内置一个.s-sopop-btn span元素组成,
  31. {
  32. cls:null, // 添加类名
  33. text:'确定', // 默认按钮文字
  34. link:'#', // 为a添加链接,添加链接后,按钮返回链接指向地址
  35. removePop: true, // 默认点击按钮关闭弹出层
  36. callback:function (removePop){} // 返回事件
  37. }
复制