標籤:
sobox 是一款非常實用的,基於 jQuery 的彈窗控制項。
功能非常完整,而代碼量又非常少(壓縮完僅8k不到)的一款彈窗控制項,
如果你熟悉ext的彈窗控制項,那麼sobox的使用對你來說應該是愉悅而完全沒有壓力。
效果預覽
引入sobox檔案
- <link type="text/css" rel="stylesheet" media="all" href="style.css" />
- <script type="text/javascript" src="jquery1.9.1.min.js"></script>
- <script type="text/javascript" src="jquery.sobox.js"></script>
複製使用方法
- $(‘.a-tip‘).click(function () {
- $.sobox.tip({
- content: ‘愛看不看,上面提示一下~‘
- });
- return false;
- });
複製sobox 基本參數
- //通用方法
- $.sobox.pop({
- /* 彈出類型及型別參數 */
- type : ‘content‘, // 彈窗內容模式:‘content‘,‘target‘,‘ajax‘,‘iframe‘,每個模式分別對應每個參量
- target : null, // target方式,target目標,如 ‘.detail‘,‘#contbox‘
- content : null, // content方式,支援html
- iframe : null, // iframe方式,值為iframe目標頁連結,如:http:// www.baidu.com/
- ajax:{url:null,data:null,callback:function(){}}, // ajax事件
-
- /* 位置資訊 */
- posType:‘center‘, // ‘center,win,doc,tc,bc‘ 位置類型,置中 / 距window頂部 / 距離doucment頂部定 / top水平置中 / bottom水平置中,預設置中
- pos:[0,0], // [x,y] 距離document左上方座標,set模式使用
- offset:[0,0], // [x,y] 彈窗相對本來設定位置位移量,center模式只改變y軸
-
- /* 自訂參數 */
- cls : null, // 添加自訂類名
- width:360,height:null, // 寬高屬性,iframe模式下,height為iframe高度
- defaultShow:true, // 直接顯示pop
- visibility:true, // 預設pop執行後顯示(用於部分複雜處理情境)
- title : ‘提示‘, // 預設標題
- showTitle:true, // 標題列隱藏:預設顯示
- showMask : true, // 顯示遮罩
- drag :true, // 是否可拖動
- maskClick : true, // 點擊背景關閉內容
- btn : [], // {cls:,text‘確定‘,link:,removePop: true,callback:}
-
- /* 返回事件 */
- beforePop:function(){}, // 彈窗開啟之前callback事件
- onPop: function(){}, // 頁面開啟callback事件
- closePop: function(){} // 點擊標題關閉按鈕返回事件
- });
-
- btn參數說明:
-
- 預設每個btn元素由一個.a-sopop-btn 的a元素內建一個.s-sopop-btn span元素組成,
-
- {
- cls:null, // 添加類名
- text:‘確定‘, // 預設按鈕文字
- link:‘#‘, // 為a添加連結,添加連結後,按鈕返回連結指向地址
- removePop: true, // 預設點擊按鈕關閉彈出層
- callback:function (removePop){} // 返回事件
- }
複製
下載
jquery.sobox 經典版彈窗控制項