By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,562 Members | 940 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,562 IT Pros & Developers. It's quick & easy.

IE gives an error and works anyway

P: n/a
Hi, it's me again!

I have a strange problem with a form I gotta (dynamically) insert in a
site, and copied/pasted the code to a blank page, to make it easier to
try it out. I was using the $ function of script.aculo.us, which is
substituted by the equivalent document.getElementById in the code below
(and the problem is still the same).
The "mystery" is that this code WORKS both in FF 2 and IE 6, but IE
gives an error at the moment when the innerHTML is executed (I tried
putting an alert before it)... my only doubt is that trying to validate
it with Dreamweaver it says that the tags in the string are nested, and
shouldn't... but IT'S JUST A STRING!!!!!
Can U help me, please? I beg U! :-)
Thanks in advance!
Massi
P.S.: yes, it's very bad-looking to see the code copied this way, and
the form's string it wouldn't work at all if I tried to "linefeed" the
string... BTW I tried to "decompress" the string, and th XHTML 1.0
Strict (still Dremweaver validator). Copying/pasting it in an editing
environment it should look much better! :-)
P.P.S.: don't take care about the CSS.. it's why I tried this code, but
it doesn't matter on the problem

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Prova</title>
</head>

<body>
<script type="text/javascript">
nome_tipo="Boh";
nome="Massi";
n_prog="enneprog";
data= new Date;
descrizione="sto cazzo";
</script>
<div id="formbox">
</div>

<script type="text/javascript">
document.getElementById("formbox").innerHTML='<for m action=""
method="post"><fieldset><legend>Parametri
Subscribers</legend><p>Inserire i nuovi parametri<br/>del subscriber
selezionato:</p><div><label for="tipo">Tipo Dispositivo<input
disabled="disabled" type="text" id="tipo" name="tipo"
value="Subscriber"/></label></div><div><label
for="ID">Identificativo<input type="text" id="ID" name="ID"
value="'+nome+'"/></label></div><div><label for="number">N&deg;
Progressivo<input type="text" id="number" name="number"
value="'+n_prog+'"/></label></div><div><label
for="descrizione">Descrizione<textarea name="descrizione"
id="descrizione" rows="3"
cols="15">'+descrizione+'</textarea></label></div></fieldset><fieldset><legend>Data
odierna</legend><label for="day" class="labelcorta">GG<input
disabled="disabled" name="day" type="text" id="day" size="2"
maxlength="2" value="'+data.getDate()+'"/></label><label for="month"
class="labelcorta">MM<input disabled="disabled" name="month" type="text"
id="month" size="2" maxlength="2"
value="'+(data.getMonth()+1)+'"/></label><label for="year"
class="labelcorta">AAAA<input disabled="disabled" name="year"
type="text" id="year" size="4" maxlength="4"
value="'+data.getFullYear()+'"/></label></fieldset><fieldset><legend>Ora
attuale:</legend><label for="ore" class="labelcorta">ora<input
disabled="disabled" name="ore" type="text" id="ore" size="2"
maxlength="2" value="'+data.getHours()+'"/></label><label for="minuti"
class="labelcorta">min.<input disabled="disabled" name="minuti"
type="text" id="minuti" size="2" maxlength="2"
value="'+data.getMinutes()+'"/></label><label for="secondi"
class="labelcorta">sec.<input disabled="disabled" name="secondi"
type="text" id="secondi" size="2" maxlength="2"
value="'+data.getSeconds()+'"/></label></fieldset><div
id="bottoni"><input type="button" value="Annulla"
onclick="togliform()"/><input type="submit" class="big"
onclick="wait();raccogliDatiUtente(\"formbox\");ad deseguito(\"Sono state
modificate le caratteristiche del subscriber selezionato\")"
value="Modifica Dati"/></div></form>';
</script>
</body>
</html>
Feb 3 '07 #1
Share this Question
Share on Google+
6 Replies

P: n/a
massic80 ha scritto:
P.S.: yes, it's very bad-looking to see the code copied this way, and
the form's string, BUT it wouldn't work at all if I tried to "linefeed" the
string... BTW I tried to "decompress" the string, and IT DOESN'T GIVE ERRORS ON XHTML 1.0
Strict (still Dremweaver validator). Copying/pasting it inTO an editing
environment it should look much better! :-)
Feb 3 '07 #2

P: n/a
massic80 ha scritto:
I also tried with w3c online validator: first, it said the DOCTYPE tag
shouldn't be closed.

In the code, remove "wait();raccogliDatiUtente(\"formbox\");", sorry! :-)

The problem goes on... w3c validator continues saying there R nesting or
overlapping problems
Feb 3 '07 #3

P: n/a
massic80 wrote:
<snip>
The "mystery" is that this code WORKS both in FF 2 and IE 6,
but IE gives an error at the moment when the innerHTML is
executed
But it is too much trouble for you to say what error is produced by IE?
(I tried putting an alert before it)... my only doubt is that
trying to validate it with Dreamweaver
Is that a joke?
it says that the tags in the string are nested, and shouldn't... but
IT'S JUST A STRING!!!!!
It may be a string to javascript but to a validator the whole thing is
(x?)HTML mark-up first, and there the nesting of tags in incorrect (the
consequence of a general failure to escape the '</' sequences in the
stirng).
Can U help me, please? I beg U! :-)
If you cannot be bothered to attempt to construct sentences from words I
am very inclined not to bother.

<snip>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
IE does not support XHTML at all, so there is little point in writing
XHTML mark-up if you are going to serve it IE.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
^^^^^^^^^
This is irrational. If you want the document interpreted as HTML you
should write HTML, and putting /at the end of a META element in the
head of a document that is to be interpreted as HTML is non-valid and may
have directly harmful consequences as its meaning in SGML may be applied
by some browsers.

<snip>
<script type="text/javascript">
document.getElementById("formbox").innerHTML='<for m action=""
The - innerHTML - property is not generally supported in XHTML DOMs (and
probably should not be expected to be supported there). Using this
construct _requires_ that this document must _never_ be interpreted as
XHTML, and so imposing the illusion of XHTML on the mark-up is not
rational.

<snip>
onclick="wait();raccogliDatiUtente(\"formbox\");
<snip ^ ^

This - onclick - attribute's value is delimited with double quotes so the
first of the double quotes used in this arguments list will end the
attribute value. So the actual attribute value is
"wait();raccogliDatiUtente(", and that will result in a syntax error when
the browser attempts to use that value to create an event handling
function. The odds are very good that FireFox is also reporting that
syntax error, though you may just not be looking for it.

Richard.

Feb 3 '07 #4

P: n/a
Richard Cornford ha scritto:
But it is too much trouble for you to say what error is produced by IE?
Here I am (I inserted HTML 4.01 strict DOCTYPE, and it's the same):
Row: 2
Char: 1
Error: syntax error
Code: 0
Try to copy/paste my code!
>(I tried putting an alert before it)... my only doubt is that
trying to validate it with Dreamweaver

Is that a joke?
mmh?
It may be a string to javascript but to a validator the whole thing is
(x?)HTML mark-up first,
Ah... I didn't know it! Thanks!
and there the nesting of tags in incorrect (the
consequence of a general failure to escape the '</' sequences in the
stirng).
what do U mean?
><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

IE does not support XHTML at all, so there is little point in writing
XHTML mark-up if you are going to serve it IE.
Pardon my maybe-fool question: I'm making an HTML interface for a local
server (in which the form would be inserted), and my only job is making
the visual part of it. Another guy is working on the Ajax/XML messages
part... would it still work if I modify the DOCTYPE to HTML 4.01?
><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
^^^^^^^^^
This is irrational.
:-O I'm really "sorry"... it's the standard head put by Dreamweaver! :-)
I trusted it!
If you want the document interpreted as HTML you
should write HTML, and putting /at the end of a META element in the
head of a document that is to be interpreted as HTML is non-valid and
may have directly harmful consequences as its meaning in SGML may be
applied by some browsers.
(sic!)
><script type="text/javascript">
document.getElementById("formbox").innerHTML='<fo rm action=""

The - innerHTML - property is not generally supported in XHTML DOMs (and
probably should not be expected to be supported there).
MMHh... OK... but it worked perfectly in the other instructions I wrote
in my site... they R in an external js file, and all work but this -
even if put in the same js
Using this
construct _requires_ that this document must _never_ be interpreted as
XHTML, and so imposing the illusion of XHTML on the mark-up is not
rational.
So, your verdict is "switch to HTML 4.01", huh?
<snip>
>onclick="wait();raccogliDatiUtente(\"formbox\") ;
<snip ^ ^

This - onclick - attribute's value is delimited with double quotes so
the first of the double quotes used in this arguments list will end the
attribute value.
WHOOPS! Yes, it was 4:30 in the morning, but I've looked at it several
times... but U'RE damn right! :-) I'll look at it again
Hope to hear from U again, U sound much expert on it ;-)
Massi
Feb 3 '07 #5

P: n/a
<snip>
>onclick="wait();raccogliDatiUtente(\"formbox\") ;
<snip ^ ^
IT WAS ONLY FOR THIS REASON! I modified the \" with \' and it doesn't
give errors now... FF didn't notice about it! And IE as usual doesn't
give the exact line of the error...
I put those \' cause I had a sentence with a "'", and I even tried
"\\\'" :-)... then I removed the "'" and leaved those wrong \"... but i
was much modified from the previous-my friend-version so I were
confused... BTW, THANKS! :-)
Now: I'm asking again about the HTML thing: do U think Ajax and XML
communications commands would still work if the page was "only" HTML 4.01?
Feb 3 '07 #6

P: n/a
massic80 said the following on 2/3/2007 12:54 PM:
><snip>
>>onclick="wait();raccogliDatiUtente(\"formbox\" );
<snip ^ ^
IT WAS ONLY FOR THIS REASON! I modified the \" with \' and it doesn't
give errors now... FF didn't notice about it! And IE as usual doesn't
give the exact line of the error...
I put those \' cause I had a sentence with a "'", and I even tried
"\\\'" :-)... then I removed the "'" and leaved those wrong \"... but i
was much modified from the previous-my friend-version so I were
confused... BTW, THANKS! :-)
Now: I'm asking again about the HTML thing: do U think Ajax and XML
communications commands would still work if the page was "only" HTML 4.01?
Did you test it? The answer is yes.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 3 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.