Javascript function call from html -


i'm doing javascript homework(total newb) , study guide says...

add document.write() statements around each line of html code (p. 53 gives example) sure keep code organized , easy read. keep in mind single (') , double (") quotes must nested avoid errors.

i've done here.

    function displayheader() {          document.write("<h1>              <img src="images/petebanner.jpg" alt="pistol pete" />              jason lemon's javascript website!               <img src="images/petebanner.jpg" alt="pistol pete" /></h1>;     }; 

when go header section of html file...i'm supposed call function. referenced javascript file in head section. here i'm putting in header section. it's not working. know code way off.

it should more ...

function displayheader() {     document.write(         '<h1>' +             '<img src="images/petebanner.jpg" alt="pistol pete" />' +              'jason lemon\'s javascript website!' +              '<img src="images/petebanner.jpg" alt="pistol pete" />' +         '</h1>';     ) } 

... using document.write bad practice, if that's assigment says, guess it's okay, know shouldn't using it.

to call function after you've included script in html, can do

<script type="text/javascript">      displayheader()  </script> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -