HTML中用了frameset ,如何在整个IE中捕获键盘事件?
HTML中可以用JAVASCRIPT,但不能用ASP等。我用的只是HTML。下面是我的index.html<frameset rows="100,180,*" cols="*" frameborder="no" border="0" framespacing="0" style="height:1500px;">
  <frame src="head01.HTM" name="topFrame" scrolling="no" noresize="noresize" id="topFrame" />
  <frame src="head02.HTM" name="top2Frame" scrolling="no" id="top2Frame" />
  <frame src="Main.HTM" name="mainFrame" scrolling="No" noresize="noresize" id="mainFrame" />
<noframes>
</noframes>
</frameset> 现在,mainFrame是根据topFrame上面的链接动态生成的。所以,mainFrame中显示的HTML不能写JS代码,
怎么样在index.html中写JS,在整个IE中捕获键盘事件?
也就是说,我想要这样的结果:不论焦点在哪个frame中,我按下热键F8后,都alert('F8');

解决方案 »

  1.   

    每个页面都设置onkeydown事件咯
      

  2.   

    一个比较笨的办法,在每个Frame里面都写事件处理函数
      

  3.   

    <html>
    <script language="javascript">
    function hello(){
    alert("hello mouse click !");
    }
    window.onload=function(){
    for(var i=0;i<frames.length;i++){
    frames[i].document.onclick = hello;
    }
    }
    </script> <frameset rows="100,180,*" cols="*" frameborder="no" border="0" framespacing="0" style="height:1500px;">
    <frame src="head01.HTM" name="topFrame" scrolling="no" noresize="noresize" id="topFrame" />
    <frame src="head02.HTM" name="top2Frame" scrolling="no" id="top2Frame" />
    <frame src="Main.HTM" name="mainFrame" scrolling="No" noresize="noresize" id="mainFrame" />  <noframes>
    </noframes>
    </frameset> 
    </html>
      

  4.   

    没注意看楼主的题目,居然是键盘事件。
    改一下再发。
    <html>
        <script language="javascript">
            function hello(){
                alert("hello key down !");
            }
            window.onload=function(){
             document.onkeydown = hello;
                for(var i=0;i<frames.length;i++){
                    frames[i].document.attachEvent("onkeydown", hello);
                }
            }
        </script>    <frameset rows="100,180,*" cols="*" frameborder="no" border="0" framespacing="0" style="height:1500px;">
            <frame src="head01.HTM" name="topFrame" scrolling="no" noresize="noresize" id="topFrame" />
            <frame src="head02.HTM" name="top2Frame" scrolling="no" id="top2Frame" />
            <frame src="Main.HTM" name="mainFrame" scrolling="No" noresize="noresize" id="mainFrame" />     <noframes>
        </noframes>
        </frameset> 
    </html
      

  5.   

    问题解决 谢谢syukugai