按下Escape键退出的快捷键

3

如何通过Esc键退出全屏iframe,使其恢复到原始大小。请为我提供JavaScript代码,因为在HTML页面中jquery无法工作。

以下是全屏iframe的代码:

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

请不要同时打开两个相同的问题 - 同时您在上面引用的内容有一个引号不足。是什么触发了iframe的大小? - mplungjan
1个回答

0
你的意思是这个吗(顺便说一下,你不能嵌入stackoverflow)?
<iframe name="myiframe1" id="frame1" src="javascript:'hello 1'" 
style="position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:999" frameborder="no"></iframe>
<iframe name="myiframe2" id="frame2" src="javascript:'hello 2'" 
style="display:none;width:300px;height:300px" frameborder="yes"></iframe>
<script>
document.onkeypress=document.onkeydown = function(evt) {
  evt = evt || window.event;
  var kc = evt.which || evt.keyCode;
  if (kc==27) {
    document.getElementById('frame2').style.display=''
    document.getElementById('frame1').style.display='none'
  } 
}
</script>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接