Problem in IE6 but not IE4

D

Dr John Stockton

Page part <URL:http://www.merlyn.demon.co.uk/js-index.htm#BC> works in
IE4 but not in IE6. IE6 says "invalid argument, apparently referring to
the "var Wid" line in the javascript section below.

IIRC, also, before the code is executed, the target area created by

<div ID="BarCht" style="position:relative;
width:360; height:340; background:silver; text-align:center;">

does not appear.


function BarChart3(F, Str) { var J, L, T, A, Min, Max, Sum, Bsw, Bsh
var Wid, Hgt, St = "Chart 3\n", TopM = 20, BotM = 20 // Margins
L = (A = Str.split(",")).length
Wid = Math.round(parseInt(BarCht.style.width) / L)


Suggestions? After pressing the Chart3 button, IE4 gives something
rather like the older <URL:http://www.merlyn.demon.co.uk/barchart.gif>.
 
D

David Dorward

Dr said:

This URL references a non-existent fragment. I'm guessing you are actually
talking about: http://www.merlyn.demon.co.uk/js-tests.htm#BC
works in IE4 but not in IE6.

Generally, this would suggest that its a Quirks Mode / Standards Mode
problem. IE6 looks at the Doctype given and uses it to guess how savvy the
author is (shame that it is such an amazingly poor metric), and if it
decides on "Smart" it turns off the emulation of a number of bugs that
appeared in earlier versions of the browser. IE4 predates this innovation.

I don't know if your Doctype triggers Standards mode - for some reason you
are using the public identifier for HTML 4.01 Transitional with the URL to
the DTD for HTML 4.01 Strict.

I suggest you use the correct Doctype Declaration for HTML 4.01 Strict:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

You could also use the correct Doctype Declaration for HTML 4.01
Transitional, but I'd suggest avoiding it (since there should be no need to
use transitional features in 2005).

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
IE6 says "invalid argument, apparently referring to
the "var Wid" line in the javascript section below.

I've never been impressed with the IE JavaScript error reporting. You might
try a browser that does a better job. Firefox for example, which complains
that "BarCht" is not defined.
IIRC, also, before the code is executed, the target area created by

<div ID="BarCht" style="position:relative;
width:360; height:340; background:silver; text-align:center;">

Your CSS is invalid. Non-zero lengths require units.

Looks like you are depending on the browser creating, for each element with
an id, a global variable of the same name containing a reference to said
element. Most don't. See
http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom

"The following document object properties are not supported in the W3C
Document Object Model" ... "id_attribute_value"
 
L

Lasse Reichstein Nielsen

Dr John Stockton said:
IE6 says "invalid argument, apparently referring to
the "var Wid" line in the javascript section below.

IIRC, also, before the code is executed, the target area created by

<div ID="BarCht" style="position:relative;
width:360; height:340; background:silver; text-align:center;">

This is invalid CSS. The width and height values needs a unit,
probably "px", i.e., "width:360px; height:340px".

If the page is in standards mode on IE6, then it will, correctly, ignore
erroneous declarations, so BarCht.style.width will be undefined.

The page's DOCTYPE is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/strict.dtd">
(inconsistently using Transitional description but strict dtd)
It should be sufficient to put IE6 into standards mode.
Wid = Math.round(parseInt(BarCht.style.width) / L)

I see no declaration of "BarCht" as a variable. Referring to DOM
elements by using their id or name as a global variable is not
generally supported across browsers.

/L
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Sun, 13
Nov 2005 00:47:22, seen in David Dorward
This URL references a non-existent fragment. I'm guessing you are actually
talking about: http://www.merlyn.demon.co.uk/js-tests.htm#BC

Apologies; you are of course right.

I suggest you use the correct Doctype Declaration for HTML 4.01 Strict:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

That does no evident harm, on that page, in IE4. Before I change the
other 150-odd pages, can you guess where, if anywhere, that might break
anything?


I've never been impressed with the IE JavaScript error reporting. You might
try a browser that does a better job. Firefox for example, which complains
that "BarCht" is not defined.


Your CSS is invalid. Non-zero lengths require units.

Indeed. In correcting the others, I'd failed to notice that as a style.

Looks like you are depending on the browser creating, for each element with
an id, a global variable of the same name containing a reference to said
element. Most don't. See
http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom

"The following document object properties are not supported in the W3C
Document Object Model" ... "id_attribute_value"

I'll look ; but meanwhile I'm supposing that using
var BarCht = document.getElementById("BarCht")
might make it work in IE6; it may be a few days before I can see.

Thanks; also to LRN.
 
R

Randy Webb

Dr John Stockton said the following on 11/13/2005 6:26 PM:
JRS: In article <[email protected]>, dated Sun, 13
Nov 2005 00:47:22, seen in David Dorward



That does no evident harm, on that page, in IE4. Before I change the
other 150-odd pages, can you guess where, if anywhere, that might break
anything?

Anywhere where there is a difference in Quirks and Strict Mode. In IE4,
you shouldn't ever see a difference. In IE6 you will though. And in
Strict Mode IE6 is less forgiving than in Quirks Mode.
I'll look ; but meanwhile I'm supposing that using
var BarCht = document.getElementById("BarCht")
might make it work in IE6; it may be a few days before I can see.

It won't make it work in IE6 if it doesn't work without it. It will make
it work in non-MS browsers though. Or rather, it will come closer to
working in non-MS browsers with it than it will without it.
 
D

David Dorward

Anywhere where there is a difference in Quirks and Strict Mode. In IE4,
you shouldn't ever see a difference. In IE6 you will though. And in
Strict Mode IE6 is less forgiving than in Quirks Mode.

Can you confirm that the Doctype the OP was using previously does trigger
Quirks mode then?
It won't make it work in IE6 if it doesn't work without it.

Unless the DTD used previously was also triggering Standards mode, and that
IE turns off its creation of global variables in that mode.
 
L

Lasse Reichstein Nielsen

David Dorward said:
Can you confirm that the Doctype the OP was using previously does trigger
Quirks mode then?

I doubt it. It should trigger standards mode according to Microsoft.
Any DOCTYPE for HTML 4 with an URL will trigger standards mode. It
doesn't depend on the content of the URL.

Unless the DTD used previously was also triggering Standards mode, and that
IE turns off its creation of global variables in that mode.

IE doesn't turn off global variables in standards mode, so no.

/L
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Sun, 13
Nov 2005 00:47:22, seen in David Dorward
Looks like you are depending on the browser creating, for each element with
an id, a global variable of the same name containing a reference to said
element. Most don't. See
http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom

I rather dislike Web pages that crash my browser, especially when plain
text seems quite adequate for the material. I especially dislike ones
that kill the operating system. And it's particularly helpful if
something about updating can be read on an older system.

###

If dropping Transitional makes IE6 stricter than otherwise, then it
seems inappropriate to drop it until IE6 becomes more frequently
accessible to me.

###

A new <URL:http://www.merlyn.demon.co.uk/js-tests.htm#BC> was uploaded
at about 19:51 GMT today (Monday).
 
D

David Dorward

Dr said:
I rather dislike Web pages that crash my browser, especially when plain
text seems quite adequate for the material. I especially dislike ones
that kill the operating system. And it's particularly helpful if
something about updating can be read on an older system.

Its valid HTML, valid CSS, and doesn't have any JavaScript. You didn't
specify what browser you are using, but I'd blame it rather then Mozilla.
If dropping Transitional makes IE6 stricter than otherwise

It doesn't. The relationship between browser's decision between Quirks mode
and Standards mode is not directly related to your choice of Strict or
Transitional. According to <any URL with
that public identifier will trigger Standards mode, so switching to Strict
won't change IEs rendering mode.
A new <URL:http://www.merlyn.demon.co.uk/js-tests.htm#BC> was uploaded
at about 19:51 GMT today (Monday).

Runs under Gecko without errors now.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Tue, 15
Nov 2005 07:56:11, seen in David Dorward
Its valid HTML, valid CSS, and doesn't have any JavaScript. You didn't
specify what browser you are using, but I'd blame it rather then Mozilla.

It was in my sig : IE4.

Runs under Gecko without errors now.

Thanks. And it is OK under IE6. I'll move it to js-misc1.htm,
probably, when I need to create js-misc1.htm.

I now have a fair approximation to a javascript analogue clock, at
<URL:http://www.merlyn.demon.co.uk/js-anclk.htm#A> (foot of page). It's
as expected in IE4; it works in IE6, but in IE4 the square case fits
symmetrically round the round dial with (IIRC) 2px to spare, but in IE6
it extends a number of px more to right and down.
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top