开发者

iframe resizing and closing using esc

In my application i want to resize iframe as On clicking "Full Screen" button iframe occupies full screen and on "Esc" key it gets into its or开发者_如何学Ciginal size.


If you mean full screen as in "beyond the browser window", that is no longer possible programmatically. It used to be possible in IE 4 / 5, but has since been abandoned for security reasons.


Handling ESC button be done this way:

  1. There should be no handler when the window is displayed.
  2. When user hits Full screen this code should be executed to handle ESC key:

    $(document).bind("keydown", function (e) {
        if (e.which === 27)
        {
            e.preventDefault();
            $(this).unbind(e);
            /* restore window size */
        }
    });
    
  3. When user hits ESC handler unbinds ESC handling as seen in the upper code and resizes the window back to normal.


I used the below code to full screen iframe but escape is not working with this. Any other way to fullscreen iframe on clicling button?

<iframe name='myiframe' id='frame' src=http://stackoverflow.com' style='position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:999'frameborder='no'></iframe> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜