Im trying to learn
JS and currently working on arrays, im making a emulation of a browser which has 3 arrays a current array, forward and back.
I seem to have problems when i its making a blank entry to begin with and not operating correctly.
Code:
<html>
<head>
<script>
var Display=new Array ()
var BackStack=new Array ()
var ForwardStack=new Array ()
function ClickEnter(){
Display.pop();
Display.push(myTest.url.value);
if (BackStack == undefined)
myTest.content.value=Display;
else
BackStack.push(myTest.content.value);
myTest.back.value=BackStack;
myTest.content.value=Display;
for (var i=0; i < ForwardStack.length;){
ForwardStack.pop()
}
myTest.front.value=ForwardStack
}
function GoBack (){
ForwardStack.push(Display);
Display.pop();
var catchpop = BackStack.pop();
Display.push(catchpop);
myTest.back.value = BackStack;
myTest.front.value=ForwardStack;
myTest.content.value = Display;
}
function GoForward (){
BackStack.push(Display);
Display.pop();
var catchpop2 = ForwardStack.pop();
Display.push(catchpop2);
myTest.back.value = BackStack;
myTest.front.value=ForwardStack;
myTest.content.value = Display;
}
</script>
<title>THE BROWSER EMULATOR</title>
</head>
<body>
<p align="center"><b><font size="5">THE BROWSER NAVIGATION DEMONSTRATOR</font></b>
<form name="myTest">
<p align="center"><b><font size="2">URL:</font></b>
<input name="url" type="text" size="20">
<br><BR>
<input type="button" value="Enter" name="Enter" Onclick="ClickEnter()"></p>
<p align="center"><b><font size="2">DISPLAY:</font></b> <input name="content" type="text" size="20"></p>
<p align="center"><textarea rows="8" name="back" cols="20"></textarea>
<textarea rows="8" name="front" cols="20"></textarea></p>
<p align="center"><input type="button" value="Backward" name="Backward" Onclick="GoBack()">
<input type="button" value="Forward" name="Forward" Onclick="GoForward()"></p>
<p>
</form>
</body>
</html>