# Designmode iFrame action alerts - please help

**URL:** https://forum.kirupa.com/t/designmode-iframe-action-alerts-please-help/233246
**Category:** web dev
**Created:** [July 21, 2007, 10:17pm UTC](https://forum.kirupa.com/t/designmode-iframe-action-alerts-please-help/233246 "2007-07-21T22:17:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Shard](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@Shard](https://forum.kirupa.com/u/Shard)
#### Post date: [July 21, 2007, 10:17pm UTC](https://forum.kirupa.com/t/designmode-iframe-action-alerts-please-help/233246/1 "2007-07-21T22:17:26Z")

</div>

Hi all, thanks for taking the time to read this.  
I have an auto-generated iframe and i need to know when a user clicks inside the iframe and also when they select some text so that I can display suitable editing buttons (if you havent already guessed - its an rte) 🙂

On the page is a simple div which has the iframe appended to it, so Iam assuming that I need to add the event handlers to the iframe creation code …

```auto
function def(){
    var testframe = document.createElement("iframe");
    testframe.setAttribute('name', 'textEditor');
      testframe.setAttribute('id', 'textEditor');
      testframe.style.width = '740px';
      testframe.style.height = '240px';
    testframe.style.background = '#ffffff';
    if (testframe.addEventListener){
        testframe.addEventListener("load",function(e){this.contentWindow.document.designMode = "on";}, false);
    } else if (testframe.attachEvent){
        testframe.attachEvent("load", function(e){this.contentWindow.document.designMode = "on";});
    }
    testframe = document.getElementById('editor').appendChild(testframe);
    textEditor.document.designMode="on";
    textEditor.document.open();
    textEditor.document.write('<head><style type="text/css">body{ font-family:arial;font-size:13px;color:black; }#basez{ clear:both;width:100%; }</style></head>');
    textEditor.document.write('<div id="basez"></div>');
    textEditor.document.close();
    textEditor.focus();
}

```

Any help greatly appreciated.
