在jQuery中传递URL参数时如何显示ColorBox对话框
我希望使用代码显示一个ColorBox对话框在jQuery中传递URL参数时如何显示ColorBox对话框,jquery,parameters,dialog,colorbox,Jquery,Parameters,Dialog,Colorbox,我希望使用代码显示一个ColorBox对话框 $(文档).ready(函数() $(“.colorbox_对话框”).colorbox(); }); 当传递url参数?dialog=yes时。在jQuery 1.3+中如何实现这一点?window.location.getQueryString=function(queryStringName){//usage-var blah=location.getQueryString(“queryStringName”); window.location
$(文档).ready(函数()
$(“.colorbox_对话框”).colorbox();
});代码>
当传递url参数?dialog=yes时。在jQuery 1.3+中如何实现这一点?window.location.getQueryString=function(queryStringName){//usage-var blah=location.getQueryString(“queryStringName”);
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();
});
var qStrings=this.search.substring(1.split(&));
对于(var i=0;i将扩展代码从添加到Javascript中。然后将上面的代码更改为:
$(document).ready(function() {
if ($.getUrlVar('dialog') === 'yes') {
$(".colorbox_dialog").colorbox();
}
});
当我想通过代码打开色盒时,我会使用此选项
$.fn.colorbox({href:'#delete-comment-div', open:true, inline:true});
其中delete comment div是我想要显示的div的id(在我的站点中它嵌套在一个隐藏的div中)。$.fn.colorbox
对我不起作用,但$.colorbox
起作用。我想这可能是因为colorbox的更新版本。