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

8 comments:

  1. good Thanks so much>>>>>

    ReplyDelete
  2. The site was so nice, I found out about a lot of great things. I like the way you make your blog posts. Keep up the good work and may you gain success in the long run.
    python Training institute in Pune
    python Training institute in Chennai
    python Training institute in Bangalore

    ReplyDelete
  3. Thank you for this post. Thats all I are able to say. You most absolutely have built this blog website into something speciel. You clearly know what you are working on, youve insured so many corners.thanks
    Data Science course in Chennai
    Data science course in bangalore
    Data science course in pune
    Data science online course
    Data Science Interview questions and answers
    Data Science Tutorial
    Data science course in bangalore

    ReplyDelete