2 Replies - 380 Views - Last Post: 05 December 2014 - 01:00 PM

#1 cdosrun1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 16-October 13

html not firing javascript function

Posted 05 December 2014 - 12:25 PM

Hi,

For some reason, my javascript code isn't working and I don't know why. My HTML and Javascript code is posted below. I tried to do it simply, with the javacsript function just doing an alert window that is called by an HTML section tag, but it isn't working. This is frustrating, because it worked for a button (like the onclick event) but not for this..



HTML Code
<html>
  <script src="mainScript.js" > </script>
<!-- Documentation tags... it's not compiled --> 
 <section onload="showAlert()"> 
     <textarea cols="100" rows="100"> </texarea>
  </section>
</html>



Javascript Code
   function showAlert(){
     alert("A");
   }





I feel like I'm not seeing something, so if someone can help me, I will love you forever.. or at least until I encounter another bug.

Is This A Good Question/Topic? 0
  • +

Replies To: html not firing javascript function

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6834
  • View blog
  • Posts: 28,360
  • Joined: 12-December 12

Re: html not firing javascript function

Posted 05 December 2014 - 12:44 PM

A section doesn't have an onload event-attribute. body and img tags, etc., do.

Supported tags are listed here.

This post has been edited by andrewsw: 05 December 2014 - 12:45 PM

Was This Post Helpful? 1
  • +
  • -

#3 cdosrun1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 16-October 13

Re: html not firing javascript function

Posted 05 December 2014 - 01:00 PM

View Postandrewsw, on 05 December 2014 - 12:44 PM, said:

A section doesn't have an onload event-attribute. body and img tags, etc., do.

Supported tags are listed here.


I knew it was something simple, thanks.

View Postandrewsw, on 05 December 2014 - 12:44 PM, said:

A section doesn't have an onload event-attribute. body and img tags, etc., do.

Supported tags are listed here.


I knew it was something simple, thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1