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
Post a Comment