I want to use onload on a textarea
element.
Trying to figure out what am i doing wrong
<textarea id="textarea_info" onload="resizeFunction()"></textarea>
now just to check if it works in javascript i'm using alert: i've tried:
document.getElementById("textarea_info").onload = function(){
alert("lop");
};
and also:
function resizeFunction(){
alert("lop");
}
i've tried onload and onLoad but that alert never got through... the js file is included correctly
There are onload and onerror events for inputs have type="image" src="..." attributes. You can use onerror by passing empty or always wrong to src and change the type to proper one when onerror event triggred: function func(input) { console. log("Input loaded"); input.
The onload event can only be used on the document(body) itself, frames, images, and scripts. In other words, it can be attached to only body and/or each external resource. The div is not an external resource and it's loaded as part of the body, so the onload event doesn't apply there.
onload is most often used within the <body> element to execute a script once a web page has completely loaded all content (including images, script files, CSS files, etc.). However, it can be used on other elements as well (see "Supported HTML tags" below).
onload is an event specific to the body , frame , iframe , img , link , and script elements.
Supported HTML tags:
<body>, <frame>, <frameset>, <iframe>, <img>, <input type="image">, <link>, <script> and <style>
see HTML onload Event Attribute
There is no such event onload for text area.
Read more about it here, about the methods, properties and events.
I assumed you want to init it with something for the first time.
For this simply do what ever you want straight away.
document.getElementById("textarea_info").WHATEVER_I_WANT_TO_DO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With