levels refer to levels of undo.
The array has 10 elements, but unless you do some scripted checking you have to ensure you don't try to add to a non-existent array location. It may just increase the size of the array, but without running the script (I am not at my machine) I can't tell, and browsers differ.
Another improvement would be to clear the contents of the last array location when you don't need it, just to keep the whole thing clean and not using too much RAM. Unless you wanted to add a feature of "re-do" which is another function again.
if(levl>0)levl = levl-1; // limit at 0!!
document.innerHTML=fred[levl]; // re-instate previous page.
fred[levl] = ""; // clear undo text now it is not required.