jquery.boxy彈出框(後隔N秒後自動隱藏/自動跳轉)

來源:互聯網
上載者:User

對於 Boxy彈出框的使用之前寫過一些文章(查看jquery.boxy基礎),今天主要是在解決一個需要之後,覺得值得把它記錄下來,所以就再寫一篇,主要功能是,在彈出對話方塊後,隔N秒後自動隱藏,還有就是自動跳轉!

效果

而所封裝的代碼如下複製代碼 代碼如下:// boxy對話方塊擴充
var Boxy_Extensions = {
options: {
title: '藝吧提示',
closeText: 'x'
},
//彈出後N秒後隱藏
alertDelayFun: function (info, timer, options) {
options = $.extend(this.options, options || {});
new Boxy("<div style='padding-left:50px;padding-right:50px;text-align:center;font-size:14px;'>" + info + "</div>", $.extend({ behaviours: function () {
setTimeout('$(".boxy-wrapper").hide();', timer);
}
}, options));
},
//彈出後,自動跳轉
alertHrefFun: function (info, href, options) {
options = $.extend(this.options, options || {});
new Boxy("<div style='padding-left:50px;padding-right:50px;text-align:center;font-size:14px;'>" + info + "</div>", $.extend({ behaviours: function () {
location.href = href;
}
}, options));
}
}

因為options屬性是公用的,所以把它提了出現,而每個方法有自己的options,如果在調用自己方法時傳遞了options,通過$.extend會把它

與類中options屬性的內容進行合并(覆蓋相關鍵的值,擴充新的索引值),看來寫JS也應該遵循物件導向的原則呀,呵呵!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.