»
EnglishFrenchVietnamese

Print - Word Scramble JavaScript - JavaScriptBank.com

Full version: jsB@nk » Game » Puzzle » Word Scramble JavaScript
URL: https://www.javascriptbank.com/word-scramble-javascript.html

Word Scramble JavaScript © JavaScriptBank.comA random word is provided to discover the word easily by clicking. You can add your own word.

Full version: jsB@nk » Game » Puzzle » Word Scramble JavaScript
URL: https://www.javascriptbank.com/word-scramble-javascript.html



CSS
<STYLE type=text/css>BODY {TEXT-ALIGN: center}A.scramble {FONT-WEIGHT: bold; FONT-SIZE: 30px; COLOR: black; POSITION: relative}SPAN#assemble {FONT-WEIGHT: bold; FONT-SIZE: 30px; POSITION: relative}SPAN#theWord {BORDER-RIGHT: gray 2px inset; BORDER-TOP: gray 2px inset; FONT-WEIGHT: bold; FONT-SIZE: 30px; BORDER-LEFT: gray 2px inset; COLOR: white; BORDER-BOTTOM: gray 2px inset; POSITION: relative; BACKGROUND-COLOR: black}A:hover {COLOR: white; BACKGROUND-COLOR: black}</STYLE><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<SCRIPT language=JavaScript type=text/javascript><!--var word=new Array("ENLIGHTENING","MAJESTIC","DISRESPECT","SCULPTURE","BLUNTNESS","SECURITY","ADEPT","AWESOME");var letter=new Array();var rand;var actual;window.onload=main;function main(){  getRand();scrambleWord();creatWord();}function scrambleWord(){ actual=word[rand]; Temp=word[rand].length;  for(var HUCKO=0;HUCKO<Temp+2;HUCKO++){ RHUCKO1=HUCKO-1;  letter[HUCKO]=word[rand].substring(RHUCKO1,RHUCKO1-1)}letter.sort();word[rand]="";for(var HUCKO=0;HUCKO<Temp+2;HUCKO++)word[rand]+=letter[HUCKO];}function getRand(){  rand=Math.floor(Math.random()*word.length);}function creatWord(){ for(var x=0;x<word[rand].length+2;x++) {  RHUCKO1=x-1;  a=document.createElement('a');a.id="aid"+x;a.className="scramble";a.innerHTML=word[rand].substring(RHUCKO1,RHUCKO1-1);a.href="javascript:append('"+x+"');";document.getElementById('board').appendChild(a); }}function creatWord2(x){  RHUCKO1=x-1;  a=document.createElement('a');a.id="aid2"+x;a.className="scramble";a.innerHTML=word[rand].substring(RHUCKO1,RHUCKO1-1);a.href="javascript:retract('"+x+"');";document.getElementById('assemble').appendChild(a);}function append(RHUCKO1){  document.getElementById('aid'+RHUCKO1).style.visibility="hidden";//document.getElementById('assemble').innerHTML+=document.getElementById('aid'+RHUCKO1).innerHTML;creatWord2(RHUCKO1);}function retract(RHUCKO1){  document.getElementById('aid'+RHUCKO1).style.visibility="visible";elem=document.getElementById('aid2'+RHUCKO1);document.getElementById('assemble').removeChild(elem);}function showWord(){  document.getElementById('theWord').innerHTML=actual;}//--></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<SPAN id=board></SPAN><BR><BR><SPAN id=assemble></SPAN><BR><BR><SPAN id=theWord></SPAN><FORM><INPUT onclick=showWord(); type=button value="->See Word"> <B style="VISIBILITY: hidden">__</B> <INPUT onclick=javascript:history.go(0); type=button value="Play Again!"></FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->