Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 515589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:38:37+00:00 2026-05-13T07:38:37+00:00

On the webpage I have iframe, in which I display some content. I want

  • 0

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 ajax (with scriptmanager on page):

Sys.UI.DomEvent.addHandler(document.getElementById('iframe1').contentWindow.document, 'keyup', iframeKeyHandler);

But I want to do it without ajax!

Updated Code:

function Init() {
    document.getElementById('iView').contentWindow.document.designMode = "on";       

     document.getElementById('iView').contentWindow.document.onkeyup = function(event) {
       alert(event);
     }    
 }

<body onload="Init()" >   
<iframe id="iView" style="width: 434px; height:371px" ></iframe>
</body> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:38:38+00:00Added an answer on May 13, 2026 at 7:38 am

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

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

    <html>
    <head>
    <script type="text/javascript">
    function Init() {
        var _win = document.getElementById("iView").contentWindow;
        var _doc = _win.document;
        _doc.designMode = "on";
        if(_doc.addEventListener) {// if support addEventListener
            _doc.addEventListener("keyup", frameKeyUp, true)
        }
        else { //For IE
            _doc.attachEvent("onkeyup", frameKeyUp);
        }
    }
    function frameKeyUp(e){
        alert(e.keyCode);
    }
    </script>
    </head>
    <body onload="Init()" >   
    <iframe id="iView" style="width: 434px; height:371px"></iframe>
    </body>
    </html>
    

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Inside a webpage I have an Excel download button, which redirects to a webpage
I have a iframe-1 and it contains another iframe-1-1 . [1] Inside iframe-1-1 which
In my code I have an iFrame which loads dynamic content it's like a
i have set up a demo which use iframe to include an target webpage
i have a webpage including 4 different iframe webpages i want that all pages
I have a webpage where I have an Iframe. When someone clicks something in
I have an iframe embedded on my webpage and I'd like to edit certain
I have an iframe where the web page inside of the iframe runs a
I have a script that dynamically loads iframes inside a webpage. You can see
according to the HTML Standards ID-Attributes of any HTML Tag in a webpage have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.