Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use onload on text area element

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

like image 331
Anamed Avatar asked May 19 '15 09:05

Anamed


People also ask

Can we use onload for input?

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.

Can I use onload on Div?

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.

Which elements can have onload?

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).

Which HTML elements support onload?

onload is an event specific to the body , frame , iframe , img , link , and script elements.


2 Answers

Supported HTML tags:

  <body>, <frame>, <frameset>, <iframe>, <img>, <input type="image">, <link>, <script> and <style>

see HTML onload Event Attribute

like image 101
Yangguang Avatar answered Oct 22 '22 21:10

Yangguang


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
like image 6
CodeWizard Avatar answered Oct 22 '22 21:10

CodeWizard