jquerythickbox

Thickbox doesn't close when Esc key is pressed when the iframe is focused


When I focus the iframe and try to push the esc key to close the window, nothing happens. I assume that it is because the focused iframe is not subscribed to this event. Does anyone have any ideas how I could attach this event to the iframe without having to manually edit each one of the pages that are contained in a thickbox?


Solution

  • This solution works in internet explorer, which happens to be the only browser my client base is using, however I would prefer a solution that at least works in firefox.

    $("#TB_iframeContent").ready(function(){
        setTimeout(function(){
            $('#TB_iframeContent').contents().find('body').keyup(function(e){
                if(e.keyCode == 27){
                    tb_remove();
                }
            });
        }, 50);
      });
    

    I add this at line 245 in the original thickbox source.