First off, the attached code is not for any project due for class or anything else.
That being said, I have found a number of 'neat' functions,
mostly recommended by other forum members,
that I usually cannot relocate when I want to use them.
("CRS" problem that occurs with maturity).
I wanted to put them into one site that I would be able to remember
with the ability to copy and paste the function into other projects.
I created a tab display that works very well in FF on PC and iMac.
However, after a certain point, the display in MSIE gets lost.
I have tried putting in selective alerts to isolate the problem,
but I don't seem to be able to put them where they do any good for me.
To see the problem, select some of the later tabs or try running some of the examples
from some of the buttons within the tab display in both MSIE and FF.
Can any one see an obvious mistake that allows all to work well in FF, but becomes buggy in MSIE?
Without a certain DTD, browsers' interpretors work in so called "quirks mode" (in opposition to the "strict mode"), which may provoke weird interpretation of CSS and javascript codes.
It is strange, if you alert the elements in the choose function, TEXT8 onwards are null for the div element. If you comment out the script that is in the TEXT7 div it works fine. For some reason it is having trouble with the document.write of the English.toString(). I found that if I change that to replace < or > it works fine then.
Change TEXT7 div to the following:
HTML Code:
<div id="TEXT7" class="TEXT"><p>
7. Represent a small bilingual lexicon as a Javascript object in the following fashion <br>
{"merry":"god", "christmas":"jul", "and":"och",
"happy":gott", "new":"nytt", "year":"år"} <br>
and use it to translate your Christmas cards from English into Swedish.<br><input type="button" onclick="Solution7()" value='Run Solution'><input type="button"
onclick="document.getElementById('Solutions').innerHTML=Solution7.toString()"
value='View Solution'><input type="button" onclick="FunctionDisplays(English)" value='View Functions'><pre>
var lexicon = {"merry":"god", "christmas":"jul", "and":"och",
"happy":gott", "new":"nytt", "year":"år"};
var spanish = {"merry":"feliz", "christmas":"navidad", "and":"y",
"happy":"feliz", "new":"nueve", "year":"anos"};
<script type="text/javascript">var str = English.toString(); document.write(str.replace(/</g,'<').replace(/>/g,'>'));</script></pre></div>
Note the changes within the script only. If you look at all your other document.write's that write out functions that contain those characters < > you will find you will want to do same to them, as they are all stopping at the first < character, typically in loop definitions. So you might want to make a function such as:
function preDW(str) {
document.write(str.replace( .... etc etc you get the picture, then use in place of your document.write's within the pre tags
edit: actually, just the '<' characters seem to need to be replaced
Last edited by astupidname; 06-25-2009 at 02:06 AM.
Bookmarks