D
D
Demon2015-10-15 14:57:29
JavaScript
Demon, 2015-10-15 14:57:29

How to pass text to textarea in iframe?

How can I pass text from a div (#test) to a textarea (#message) that is in an iframe window on click.
<div id="test">Передано в textarea iframe</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2015-10-15
@NeiroNx

You need to get the DOM object of the iframe document, select the desired element in it and set its value.

var text = this.innerHTML;
var iframe = document.getElementById('iframe1');
var textarea = iframe.document.getElementById('textarea1');
textarea.value += text;

could be so
<div id="test" onclick="document.getElementById('iframe1').document.getElementById('textarea1').value +=this.innerHTML">Передано в textarea iframe</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question