Aaron Gray said the following on 11/13/2005 11:56 AM:
Hi,
I have some code I just cannot seem to get to work properly on FireFox. It
is probably something simple.
On FireFox the following code does not seem to terminate in the browser, but
it works fine on IE :-
http://angray.members.beeb.net/Test/Test5.html
Check the JS Console. It gives this error message in Firefox:
Warning: Element referenced by ID/NAME in the global scope. Use W3C
standard document.getElementById() instead.
Source File:
http://angray.members.beeb.net/Test/Test5.html
Line: 30
Your code:
<FORM name=input onsubmit="return false;" action="">
You may want to rename your form to something less likely to cause a
problem. input is not a reserved word but less likely to cause confusion
if you name it something like myInputForm or myForm.
Your code:
<FORM name=result onsubmit="return false;" action="">
<INPUT type="Text" size=75 name="result">
</FORM>
Your form and your input have the same name. What does result refer to?
The form or the input? Name them differently.
Your code:
<script type="text/javascript">
function go()
{
output.document.body.innerHTML="";
output.document.writeln( "<font face='Arial'>");
output.document.writeln( "Test");
result.result.value = "10";
output.document.writeln( "</font>");
Here, you reference output as a global variable but it is not defined
anywhere. That is the cause of the Firefox error but in this case
Firefox's error message is actually incorrect. Do not use gEBI to access
form elements, use the form collection. Use the frames collection to
access IFrames.
Give this version a try:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Frame test</title>
<script type="text/javascript">
function go()
{
window.frames['output'].document.open();
window.frames['output'].document.writeln( "<font face='Arial'>");
window.frames['output'].document.writeln( "Test");
document.forms['myResult'].elements['myResult2'].value = "10";
window.frames['output'].document.writeln( "<\/font>");
window.frames['output'].document.close();
}
</script>
</head>
<body>
<h2>Frame test</h2>
<p>
<FORM name="myResult" onsubmit="return false;" action="">
<div>
<INPUT onclick="go()" type="button" value="Go">
<INPUT type="Text" size=75 name="myResult2">
</div>
</FORM>
<iframe name="output" style="width:100%;height:25%"></iframe>
</body>
</html>
Compare the two versions and see if you can tell the difference.
I left your font tags in, even though I don't care for the font tag and
it is irrelevant to your question.