javascript not generating in browser, just prints code to screen -
First of all, I'm not asking anyone to do my homework, this means a simple to get acquainted with javascript Had to write a webpage. It generates a random card from a folder called 'card' and shows that I completed that part though, when I handed it to the teacher, then they sent me the screenshot the subject line "Back with any ideas"?
I have tested this page on several machines and it works in every browser. I do not know that when he runs it, it prints the code on the page. any idea? (I'm assuming Javascript will be enabled, especially when everyone in my class submits this program).
EDIT: Here is the code, sorry, but I've included everything to clear some questions
& Lt; Title & gt; Aaron Gamble page! & Lt; / Title & gt; & Lt; Style type = "text / css" & gt; * {Padding: 0; Margin: 0; } Body {font-family: aerial, helvetica, sans-serif; Font-size: 13px; Background: # 48454C; } #wap {margin: 0 auto; Width: 365px; } #harders {Color: # 333; Width: 365px; Padding: 10px; Margin: 10px 0px 0px 0px; Background: # A29EA2; } #centercolumn {color: # 333; Padding: 10px; Width: 365px; Background: # DFE0DB; } #footer {width: 365px; Clean both; Color: # 333; Background: # A29EA2; Padding: 10px; } & Lt; / Style & gt; & Lt; Script type = "text / javascript" charset = "UTF-8" & gt; // This page created by Aaron Albine // Created date: October 17, 2009 var score = 0; Function Generated Cards () {var i, randType, randSuite; Var type = new array ("2", "3", "4", "5", "6", "7", "8", "9", "t", "j", "q" Kashmir "," A "); Var Suite = New Array ("C", "D", "S", "H"); Var card = new array (5); (Card) [i] = setRandomCard (type, suit, card) for (i = 0; i & lt; card.length; i ++); Document.write ('& lt; img src = "' + card [i] + '" & gt;'); }} Function setRandomCard (type, suite, card) {var RANDTYPE, RAND SUITE; Var filePath = "file: // C: / cards /"; Var fileExt = ".gif"; Do {randType = Math.floor (Math.random () * type.length); Rand Suite = Math Floor (Math.Rendum (* * Suite. Lamp); } While (checkduplicate (randetype, rand suite, filespath, fileext, type, suite, card)); AddScore (type, RANDTYPE); Return filepath + type [RANDTYPE] + suite [RANDSITE] + FILE EXT; } Function check duplicate (RANDTYPE, RAND SUITE, FILEPATH, FILE EXT, type, suite, card) {var j; For (J = 0; J.L. L. Cards; Lath; J ++) {if (cards [j] == filePath + type [randType] + suite [randSuite] + fileExt) {Return true; } } return false; } AddScore function (type, randomtype) {switch (type [randomtype]) {case "2": score + = 2; break; Case "3": Score + = 3; break; Case "4": Score + = 4; break; Case "5": Score + = 5; break; Case "6": Score + = 6; break; Case "7": Score + = 7; break; Case "8": Score + = 8; break; Case "9": Score + = 9; break; Case "T": Score + = 10; break; Case "h": Score + = 11; break; Case "q": Score + = 12; break; Case "K": Score + = 13; break; Case "a": Score + = 1; break; Default: Score + = 0; }} & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "wrapper" & gt; & Lt; Div id = "header" & gt; & Lt; / Div & gt; & Lt; Div id = "centercolumn" & gt; & Lt; H2 & gt; Gamble and lt; / H2 & gt; & Lt; Br / & gt; & Lt; P & gt; Welcome to my gambling page! You've pulled & lt; / P & gt; & Lt; Br / & gt; & Lt; Script type = "text / javascript" charset = "UTF-8" & gt; Generated Cards (); & Lt; / Script & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; P & gt; The value of this hand & lt; Script type = "text / javascript" charset = "UTF-8" & gt; Document.write (score); & Lt; / Script & gt; & Lt; / P & gt; & Lt; Br / & gt; & Lt; / Div & gt; & Lt; Div id = "footer" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Are you certain that your code is listed within the rights tags?
& lt; Script type = "text / javascript" charset = "utf-8" & gt; // Your code goes here & lt; / Script & gt;
This is the only reason I can imagine
Comments
Post a Comment