HTML inline javascript function not working -
the issue having running same javascript file lastmodified.js has 2 function wich make random array spit out sentence basic.html , lastmodified function issue lastmodified updates basic2.html not basic2.html how put functions inside lastmodified.js instead of making huge function , having ids of html = name doing putting id on htmls , seeing if exist if code runs
lastmodified.js--------------------------------------- window.onload=lastmodified; function lastmodified(){ //var lastmodified = document.getelementbyid("modified"); //lastmodified.innerhtml=modified; //document.write(document.lastmodified); var words1= ["yo", "ey", "vato", "esse", "mathematical", "algebraic" ]; var words2= ["wassup", "que", "wassapinin", "oooooooooooooooooooo", "oooooo"]; var words3= ["homie", "dogg", "pimp", "thug"]; var rand1=math.floor(math.random() *words1.length); var rand2=math.floor(math.random() *words2.length); var rand3=math.floor(math.random() *words3.length); var phrase = words1[rand1] + " " +words2[rand2] + " " + words3[rand3]; var phraseelement = document.getelementbyid("phrase"); phraseelement.innerhtml=phrase; document.lastmodified=lastmod; var el = document.getelementbyid('modified'); el.innerhtml=lastmod; /* modify lastmodified print format var dt = document.lastmodified; dt = dt.replace("/", " "); dt = dt.replace("/", " "); dt = dt.replace("-", " "); dt = dt.replace("-", " "); // '/' or '-' replcae these separtors empty space // string can parsed date object var anotherdateobject = new date(date.parse(dt)); alert(anotherdateobject + " -- " + anotherdateobject.gethours()); */ } end of lastmodified.js------------------------------------- basic2.html------------------------------------------------ <html> <body> <head> <title> building blocks html</title> <script src="lastmodified.js"></script> <meta name="keywords" content="html, hyper text markup language, /> <meta name="description" content="html in easy steps. introductory tutorial beginners." / > <meta name="author" content="miguel castaneda" /> <meta name="robots" content="all, nofollow" /> </head> <center><a href="#bottom">bottom</a></center> <p id="credit"> <!-- browser picks first 1 in array if not in cpu goes 2nd font //--> <tt> programmer: miguel castaneda(isten23) <br></br>last modified: <p id="modified"></p> <br></br> head first html5 programming <br></br> </p> <p> page two</p> </tt> <a name="bottom"> <p id="screensize">screen size: </p> <table><tr><td> <center><small><small> <a href="basic.html"><img src="arrow1.jpg" height="40" width="40"border="0" alt="link next page"></a> <p id="location"></p> </small></small></center></td><td> <center><small><small> <a href="basic3.html"><img src="arrow.jpg" height="40" width="40"border="0" alt="link next page"></a> </small></small></center></td> <tr></table> </body> </html> end of basic2.html basic.html----------- <!doctype html"> <html lang="en"> <html> <body> <head> <script src="lastmodified.js"></script> <link href="mainsite.css" rel="stylesheet"> <meta name="keywords" content="html, hyper text markup language, /> <meta name="description" content="html in easy steps. introductory tutorial beginners." / > <meta name="author" content="miguel castaneda" /> <meta name="robots" content="all, nofollow" /> <!-- <meta http-equiv="refresh" content="5"> refreshes same page every 5 seconds //--> <!-- <meta http-equiv="refresh" content="5"; url=pathname refresh page or url=http refresh url //--> <!-- <meta name="robots" content="all, nofollow" /> //instruct robot read page not follow links <meta name="robots" content="none" /> //instruct robot prevent reading pages @ //--> <title>building blocks html</title> </head> <!-- background="photos\codingbg.jpg bg p make pargraphs diffrent color <p><font face="arial" size="2" color="#0000ff">this tezt blue</font></p> //--> <center><a href="#bottom">bottom</a></center> <p id="credit"> <!--<font face="arial, hevetica, sans-serif"> //--><!-- browser picks first 1 in array if not in cpu goes 2nd font //--> <tt> programmer: miguel castaneda(isten23) <br></br>last modified: <div id="modified"></div> <br></br> head first html5 programming <br></br></tt> <b><big><big><center>main site</center></big></big></b> </p> <hr></hr> <p>update code every section has id can link throughout page</p> <br></br> <h3>h1- h6</h3> <p id="testh1thru6"> <h1>this h1</h1> <h2>this h2</h2> <h3>this h3</h3> <h4>this h4</h4> <h5>this h5</h5> <h6>this h6</h6> </p> <hr></hr> <p id="englishp" lang="en-us">paragraph in english</p> <p id="francais" lang="fr">paragraphe en francais</p> <hr></hr> <h3>bold, italics, subscript , superscript, inserted/deleted text</h3> <p><b>bold</b> = < b> <br></br> <i>italics</i> = < i> <br></br> <sub>subscript</sub> = < sub> <br></br> <sup>superscript</sup> < sup> <br></br> <ins>inserted text</ins> = < ins> <br></br> <del>deleted text</del>= < del> <br></br> <tt>teletype text</tt> <br></br> <p id="text">this paragraph includes words <b> bold</b>, <i>italics</i>, superscript e=mc<sup>2</sup> , subscript co<sub>2</sub> <ins>inserted text </ins>and <del>deleted text</del> <tt>teletype text</tt></p> <hr></hr> <h3>break , horizontal rule</h3> <p> break(new line) = < br> <br></br> horizontal line = < hr></p> <br></br> <p> put new line anywhere need to<br> break</br></p> <p>for there horizontal line need hr <hr>like so</hr></p> <br></br><br></br>3 <hr></hr> <h3>strong & emphasis</h3> <p>just use < b> or < i> instead of em , strong</p> <br></br> <p> strong , bold both same</p> <p> em , italics same</p> <hr></hr> <h3>quotations</h3> <p>blockquote when quote long , want link url <br></br>blockquote = < blockquote cit="url">< p> did ever think, , forget start< /p> <br></br> quote = < q>, quote had cite attribute</p> <br></br> <blockquote cite="http://en.wikipedia.org/wiki/ winnie-the-pooh"> <p>did ever stop think, , forget start again?</p> </blockquote> <p>as a.a. milne said, <q>some people talk animals. not many listen though. that's problem.</q></p> <hr></hr> <h3>abbreviations & acronyms</h3> <p>to abbr < abbr title="professor">prof< /abbr> </p> <p> html uses < abbr> element both abbreviations , acronyms.</p> <br></br> <p><abbr title="professor">prof</abbr> stephen hawking theoretical physicist , cosmologist.</p> <p><acronym title="national aeronautics , space administration">nasa</acronym> crazy space stuff.</p> <br></br> <hr></hr> <h3>orderded list</h3> <p>for order list start list < ol> , each item include < li> text < /li> < /ol> </p> <ol> <li>chop potatoes quarters</li> <li>simmer in salted water 15-20 minutes until tender</li> <li>heat milk, butter , nutmeg</li> <li>drain potatoes , mash</li> <li>mix in milk mixture</li> </ol> <br></br> <hr></hr> <h3>unordered list</h3> <p>same orderded list except use < ul> surround items </p> <br></br> <ul> <li>1kg king edward potatoes</li> <li>100ml milk</li> <li>50g salted butter</li> <li>freshly grated nutmeg</li> <li>salt , pepper taste</li> </ul> <br></br> <hr></hr> <h3>deinition lists</h3> <p> start < dl> < /dl> ever term include < dt> , definition include < dd> <br></br> <dl> <dt>sashimi</dt> <dd>sliced raw fish served condiments such shredded daikon radish or ginger root, wasabi , soy sauce</dd> <dt>scale</dt> <dd>a device used accurately measure weight of ingredients</dd> <dd>a technique scales removed skin of fish</dd> <dt>scamorze</dt> <dt>scamorzo</dt> <dd>an italian cheese made whole cow's milk (although traditionally made buffalo milk)</dd> </dl> <p id="leftoff">left off on page 68</p> <hr></hr> <p> updated 3/4/2014 </p> <h1>phrase-o-matic says:</p> <p id="phrase"></p> <hr></hr> <p>geo-location book 2 page 173 </p> <div id="location"> location go here</div> <hr></hr> <font color="purple"><p > paragraph supposed purple</p></font> <p id="purplesentence">this sentence later moved purple css</p> <hr></hr> <small> <p>site picking hexadecimal html , css</p> <p><a href="www.w3schools.com/tags/ref_colorpicker .asp">w3schools html color</a> </p></small> <hr></hr> <a name="bottom"> <center><small><small><a href="basic2.html"><img src="arrow.jpg" height="40" width="40"border="0" alt="link next page"></a></small></small></center> </body> <center> <small><small> <div id="nav"> <table> <tr><th> <a href="index.html">home</a> </th><th> <!-- 5 table spacing links//--> <a href="html.html">html</a> </th><th> <a href="python.html">python</a> </th><th> <a href="widgets.html">widgets</a> </th><th> <a href="contact_us.html">contact us</a> </tr></th> </table> </div> </small></small> </center> </table> </html> basic.html end of file
not sure if want using "onload" (what html tags support onload javascript event?)
try inlining js, , referencing element:
<p id="modified2"></p> <script type="text/javascript"> var el = document.getelementbyid('modified2'); mymod.call(el); </script>
Comments
Post a Comment