tags:

views:

305

answers:

1

I have an iframe in an HTML page, how can I cause it to act as a textarea?

+3  A: 

set contenteditable property to true

Sets or retrieves the string that indicates whether the user can edit the content of the object.

Security Alert: Users can change the contents of a Web page when the contentEditable property is set to TRUE. Using this property incorrectly can compromise the security of your application. Incorrect use of the contentEditable property might include not validating user input. If you do not validate user input, a malicious user can inject control characters or script that can harm your data. You should take routine precautions against displaying unvalidated user input.

Also take a look at

Converting an app using document.designMode from IE to Mozilla.

Eg:

<IFRAME id="txtContent" name="txtContent" src="Content.htm"</IFRAME>

and in the Content.htm page

<script language="javascript">
    function InitializeIFrame()
    {    
     document.body.contentEditable = true;    
    }
</script>

<body onload="InitializeIFrame();">

</body>
rahul