我期待展現出彩盒對話框傳遞,使用代碼如何顯示彩盒對話框時,URL參數在jQuery的
$(document).ready(function() $(".colorbox_dialog").colorbox(); });
當URL參數?對話框= yes,則通過。我如何在jQuery 1.3+中做到這一點?
我期待展現出彩盒對話框傳遞,使用代碼如何顯示彩盒對話框時,URL參數在jQuery的
$(document).ready(function() $(".colorbox_dialog").colorbox(); });
當URL參數?對話框= yes,則通過。我如何在jQuery 1.3+中做到這一點?
window.location.getQueryString = function(queryStringName) { //usage - var blah = location.getQueryString("queryStringName");
var qStrings = this.search.substring(1).split("&");
for (var i=0;i<qStrings.length;i++)
{
var pair = qStrings[i].split("=");
if (pair[0] == queryStringName) return decodeURIComponent(pair[1].replace(/\+/g, " ")); //str = str.replace(/find/g,」replace」)
}
return null;
}
$(document).ready(function() {
var dialog = location.getQueryString("dialog");
if (dialog == "yes") $(".colorbox_dialog").colorbox({open:true});
else $(".colorbox_dialog").colorbox();
});
將從http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html的擴展代碼添加到您的Javascript。然後更改上面的代碼:
$(document).ready(function() {
if ($.getUrlVar('dialog') === 'yes') {
$(".colorbox_dialog").colorbox();
}
});
我用這個當我想打開colorboxes直通碼
$.fn.colorbox({href:'#delete-comment-div', open:true, inline:true});
如果刪除註釋-DIV是div的id我想顯示(在我的網站它嵌套在一個隱藏的股利)。
'$ .fn.colorbox'不適用於我,但'$ .colorbox'確實。我認爲這可能是由於更新版本的colorbox。 – 2013-08-09 18:23:25