Form not terminating on FireFox

V

VK

Aaron said:
Sorry the JavaScripts stopped working on IE. Works on FireFox but FireFox is
not terminating still.

Your code contains a conglomerate of HTML and JavaScript error :-(
As usual IE is the most durt tolerant browser on the market :)

Here is the more proper version. A cannot comment on each change mage,
try to guess yourselve, ask only if no way.

<html>
<head>
<title>Frame test</title>
<script type="text/javascript">
function go()
{
var doc = self.frames['output'].document;
doc.open("text/html");
doc.writeln("<font face='Arial'>");
doc.writeln("Test");
document.forms['result'].elements['txt01'].value = 10;
doc.writeln("</font>");
doc.close();
}
</script>
</head>

<body onload="go()">

<h2>Frame test</h2><br>
<br>

<iframe name="output" width="100%" height="50%"></iframe>

<br>

<FORM name="result">
<label for="txt01">Result:</label>
<input type="text" name="txt01" value="">
</FORM>

</body>
</html>
 
D

David Dorward

Aaron Gray wrote:


Google aren't asking for free help in solving problems with their code. If
they want to ignore useful, but trivial to implement, QA then that is there
choice and we can roll our eyes at them. On the other hand, if you want a
bunch of complete strangers to help you, then you can show a little respect
by fixing problems that well known and free software can detect for you
before asking your questions.
 
A

Aaron Gray

Your code contains a conglomerate of HTML and JavaScript error :-(

Ah said:
var doc = self.frames['output'].document;
doc.open("text/html"); ...
doc.close();

doc.open and doc.close seem to be the real solution !

Thanks,

Aaron
 
R

Randy Webb

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.
 
A

Aaron Gray

Food for trolls :)
Google aren't asking for free help in solving problems with their code. If
they want to ignore useful, but trivial to implement, QA then that is
there
choice and we can roll our eyes at them. On the other hand, if you want a
bunch of complete strangers to help you, then you can show a little
respect
by fixing problems that well known and free software can detect for you
before asking your questions.

I normally use HTML validation as the last part of the process. But like
Google I ignore it most of the time as it does not really seem to be very
helpful most of the time, just a pain in the backside :(

Aaron
 
R

Randy Webb

Aaron Gray said the following on 11/13/2005 1:05 PM:
Your code contains a conglomerate of HTML and JavaScript error :-(


Ah said:
var doc = self.frames['output'].document;
doc.open("text/html");
...

doc.close();


doc.open and doc.close seem to be the real solution !

open() and close() were not the only problems though.
 
T

Thomas 'PointedEars' Lahn

VK said:

The DOCTYPE declaration is missing.

The character set declaration via `meta' element is missing.
<title>Frame test</title>
<script type="text/javascript">

It should be noted that due to review of the now Informational RFC
"Scripting Media Types" in the IETF, the text/javascript MIME type
has been registered in the standards tree to be obsoleted by the
also registered MIME type application/javascript.

<http://www1.ietf.org/mail-archive/web/ietf-announce/current/msg01349.html>
function go()
{
var doc = self.frames['output'].document;
doc.open("text/html");

The argument of document.open() is bogus, it will not be interpreted in
a UA standards compliant in this regard, including all Gecko-based UAs.
Instead, the Content-Type of the resulting document will be always
text/html.
doc.writeln("<font face='Arial'>");
doc.writeln("Test");
document.forms['result'].elements['txt01'].value = 10;
doc.writeln("</font>");

Deprecated usage of the `font' element aside, this is not Valid HTML as
ETAGO delimiters are not properly escaped. The above line should read

doc.writeln("<\/font>");

More important is that the resulting document is not a Valid HTML
document as the context in which the `font' element is allowed
is not generated as well.
[...]
<body onload="go()">

<h2>Frame test</h2><br>

This should be an `h1' element. As all `hX' elements are block elements,
the adjacend `br' element is neither necessary nor prudent.

Use CSS to format margins, not `br' elements.
<iframe name="output" width="100%" height="50%"></iframe>

This element is missing alternative content to be displayed if the
`iframe' element is not supported or "output" cannot be displayed.

See above.
<FORM name="result">
<label for="txt01">Result:</label>
<input type="text" name="txt01" value="">

The `label' element is not supposed to work as perhaps expected by
the poster. The value of the `for' attribute has to be an ID.


PointedEars
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 11/13/2005 1:23 PM:
The DOCTYPE declaration is missing.

Off-topic and irrelevant to this thread.
The character set declaration via `meta' element is missing.

Off-topic and irrelevant to this thread.

But, the character set is not required so it is missing if of no
consequence. What matters is if the server sends it correctly in a
web-based environment which is the default assumption in this group.
It should be noted that due to review of the now Informational RFC
"Scripting Media Types" in the IETF, the text/javascript MIME type
has been registered in the standards tree to be obsoleted by the
also registered MIME type application/javascript.
<http://www1.ietf.org/mail-archive/web/ietf-announce/current/msg01349.html>
<http://www.iana.org/assignments/media-types/>

Irrelevant to this thread.
function go()
{
var doc = self.frames['output'].document;
doc.open("text/html");

The argument of document.open() is bogus, it will not be interpreted in
a UA standards compliant in this regard, including all Gecko-based UAs.
Instead, the Content-Type of the resulting document will be always
text/html.

Still irrelevant to the problem.
doc.writeln("<font face='Arial'>");
doc.writeln("Test");
document.forms['result'].elements['txt01'].value = 10;
doc.writeln("</font>");

Deprecated usage of the `font' element aside, this is not Valid HTML as
ETAGO delimiters are not properly escaped. The above line should read

doc.writeln("<\/font>");

Off-topic and irrelevant to this thread.
More important is that the resulting document is not a Valid HTML
document as the context in which the `font' element is allowed
is not generated as well.

Off-topic and irrelevant to this thread.
[...]
<body onload="go()">

<h2>Frame test</h2><br>
This should be an `h1' element. As all `hX' elements are block elements,
the adjacend `br' element is neither necessary nor prudent.

Off-topic and irrelevant to this thread.
Use CSS to format margins, not `br' elements.

Off-topic and irrelevant to this thread.
This element is missing alternative content to be displayed if the
`iframe' element is not supported or "output" cannot be displayed.

Off-topic and irrelevant to this thread.
See above.

Off-topic and irrelevant to this thread.
The `label' element is not supposed to work as perhaps expected by
the poster. The value of the `for' attribute has to be an ID.

Off-topic and irrelevant to this thread.


If there is nothing you can add that is even remotely relevant to the
thread and the problem then please STFU and SIYC.
 
R

Randy Webb

V

VK

Aaron said:
open and doc.close seem to be the real solution !

Not really. As I said it was a complex agglomeration of wrong technics,
and open() / close() may just happened to be the last drop.
Usially you can skip on open() / close() methods: inputStream get open
and closed automatically. It is not formally correct but tolerated by
majority browsers (including Firefox).
 
R

Randy Webb

VK said the following on 11/13/2005 2:01 PM:
Not really. As I said it was a complex agglomeration of wrong technics,
and open() / close() may just happened to be the last drop.
Usially you can skip on open() / close() methods: inputStream get open
and closed automatically. It is not formally correct but tolerated by
majority browsers (including Firefox).

No, they do not get closed automatically. Comment out the close() line
in Firefox and test it. Firefox does not automatically close it and
displays the behavior the OP was complaining about. IE auto closes it.

And that behavior (auto closing) shouldn't be surprising in a "Do what
you think I want, not what I tell you to do" browser.
 
V

VK

No, they do not get closed automatically. Comment out the close() line
in Firefox and test it. Firefox does not automatically close it and
displays the behavior the OP was complaining about. IE auto closes it.

Oh... Things changed then. I personally did not use document.write()
since NN 4.x (for layer updates) and it did not require close() though
I always used it.

That's indeed a bit of hypercorrectness syndrom (one of youthhood
problems ? :)
 
R

Richard Cornford

VK said:
Oh... Things changed then. I personally did not use document.write()
since NN 4.x (for layer updates) and it did not require close() though
I always used it.
<snip>

So once again you don't let know knowing what you are talking about
stand in the way of your pontificating on the subject? It is actually
well known that many browsers do not automatically close documents
following a write operation, it is even clearly expressed in the W3C
HTML DOM standard that automatic document closing should not be expected
(while opening on a write operations is required).

Richard.
 
R

RobG

Aaron said:
Your code contains a conglomerate of HTML and JavaScript error :-(

Ah said:
var doc = self.frames['output'].document;
doc.open("text/html");

the open() method does not take any arguments:

open
Note. This method and the ones following allow a user to add to or
replace the structure model of a document using strings of unparsed
HTML. At the time of writing alternate methods for providing similar
functionality for both HTML and XML documents were being considered.
The following methods may be deprecated at some point in the future
in favor of a more general-purpose mechanism.

Open a document stream for writing. If a document exists in the
target, this method clears it.
No Parameters
No Return Value
No Exceptions

<URL:http://www.w3.org/TR/2000/WD-DOM-Level-2-HTML-20001113/html.html#ID-72161170>


A useful guide to the use of document.write(), open() and close is here:

<URL:http://developer.mozilla.org/en/docs/DOM:document>

A call to either write or writeln methods after the document has loaded
will automatically call the open method and clear the document.

[...]
 
T

Thomas 'PointedEars' Lahn

RobG said:
Aaron said:
Your code contains a conglomerate of HTML and JavaScript error :-(

Ah said:
var doc = self.frames['output'].document;
doc.open("text/html");

the open() method does not take any arguments:
[...]
<URL:http://www.w3.org/TR/2000/WD-DOM-Level-2-HTML-20001113/html.html#ID-72161170>

The statement is correct, however the reference is outdated. You are
inappropriately and needlessly referring to a Working Draft (WD) where
a Recommendation (REC), and, as such, a Specification and Web Standard
has been published long ago.

<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-72161170>

(See also <where I already
explained this.)


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top