Showing posts with label close thickbox. Show all posts
Showing posts with label close thickbox. Show all posts

Wednesday, October 28, 2009

Javascript : Close Thickbox and Refresh parent page

Choice 1 : When click the grey overlay, or close link or press escape key will remove ThickBox and refresh the parent page.

In the thickbox.js, add a line in the tb_remove() function
function tb_remove() {
$("#TB_imageOff").unbind("click");
$("#TB_closeWindowButton").unbind("click");
$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
$("#TB_load").remove();
if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
$("body","html").css({height: "auto", width: "auto"});
$("html").css("overflow","");
}
document.onkeydown = "";
document.onkeyup = "";
parent.location.reload(1); // Add this line
return false;
}

Choice 2 : Click a button to close the thickbox and refresh the parent page
<button onClick="parent.tb_remove(); parent.location.reload(1)">Close It</button>

Taken From : http://jquery.com/demo/thickbox/

Related Links:
Lightbox 2
Fancybox