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:
- There should be no handler when the window is displayed.
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 */ } });
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>
精彩评论