Adding event handler to iframe to invoke on keyup

后端 未结 1 796
醉梦人生
醉梦人生 2021-01-28 03:05

On the webpage I have iframe, in which I display some content.
I want to run a function if any key is pressed inside iframe (iframe is editable).

I can do it using a

1条回答
  •  伪装坚强ぢ
    2021-01-28 03:52

    I guess you meant "do it without using the script manager"?

    You can do it this way (use attactEvent/addEventListener):

    
    
    
    
       
    
    
    
    

    Or using jQuery's event handler for "keyup":

    $('#iframe1').keyup(function(event){
      //... do your stuff here ..
      //use event.keyCode to get the asscoiated key
    });
    

    More info on keyboard event arg can be found here and here.

    0 讨论(0)
提交回复
热议问题