So basically I have this Iframe
<iframe src ="http://.../iframe.php" id="myIframe"></iframe>
and the only thing on this iframe page (iframe.php) is a textarea:
<textarea id="test" name="text" rows="20" cols="50" readonly>
I tried scrolling the textarea down if the value of the textarea exceeds the iframe window (on the page with the Iframe on it) but it just wont work. I tried a few solutions on stackoverflow but nothing worked for me.
UPDATE
It's working now. Working code if everyone is interested:
function myFunctiontest() {
var goddammit = document.getElementById('myIframe').contentWindow.document.getElementById('test');
goddammit.scrollTop = goddammit.scrollHeight;
}
Try oninput="this.scrollTop = this.scrollHeight;"
in the textarea and if it works do it properly with the event handler.
Update:
In the page that contains the <iframe>
, it has an id as well as the textarea:
window.onload = function () {
var ifr = document.getElementById('ifr'),
ta = ifr.contentDocument.getElementById('ta');
ta.scrollTop = ta.scrollHeight;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.