469,345 Members | 6,515 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,345 developers. It's quick & easy.

Why is this happening? IE7 only error

Hi All;

Two links here, exactly the same js code. Forms are
slightly different.

This works in both FF and IE7

http://68.147.197.6/calgarydj/sampleA.htm

This one FAILS in IE7 (only) with the message ...
Object doesn't support this property or method.

http://68.147.197.6/calgarydj/sampleB.htm

Why? How do you solve something like this?

Cheers
Jim
Mar 2 '07 #1
7 4640
Diogenes wrote:

Oh yeah, I forgot. Click on any calendar day to activate the
script.
Hi All;

Two links here, exactly the same js code. Forms are slightly different.

This works in both FF and IE7

http://68.147.197.6/calgarydj/sampleA.htm

This one FAILS in IE7 (only) with the message ...
Object doesn't support this property or method.

http://68.147.197.6/calgarydj/sampleB.htm

Why? How do you solve something like this?

Cheers
Jim
Mar 2 '07 #2
Diogenes said the following on 3/1/2007 8:47 PM:
Hi All;

Two links here, exactly the same js code. Forms are slightly different.

This works in both FF and IE7

http://68.147.197.6/calgarydj/sampleA.htm

This one FAILS in IE7 (only) with the message ...
Object doesn't support this property or method.

http://68.147.197.6/calgarydj/sampleB.htm

Why? How do you solve something like this?
You start by removing code until you get a minimum case where it fails.
Scale it down to the minimum. Then you will find your error. It has a
lot to do with the format/eval'ing of the 'old' variable.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 2 '07 #3
On Mar 2, 11:47 am, Diogenes <nos...@nospam.netwrote:
Hi All;

Two links here, exactly the same js code. Forms are
slightly different.

This works in both FF and IE7

http://68.147.197.6/calgarydj/sampleA.htm

This one FAILS in IE7 (only) with the message ...
Object doesn't support this property or method.

http://68.147.197.6/calgarydj/sampleB.htm

Why? How do you solve something like this?
You have a div with id edate and an inferred global variable edate.
IE will create a global variable for the div since it is declared
before you try to assign a value to the inferred global edate.

When you try to assign a date object to edate, IE barfs. There are a
couple of solutions:

- keep the javascript variable edate local to the function (which you
should have done anyway)

- Change the name of either the div or the variable

- Don't use the variable at all (it isn't necessary)

I'd suggest that where you have:

str = year + ',' + (month-1) + ',' + day + ',19,0,0'
old = s3 = 'new Date(' + str + ')'
edate = eval( old )
document.getElementById('title').innerHTML = edate.toString()
you should use (wrapped for posting):

document.getElementById('title').innerHTML =
new Date(year, (month-1), day, 19, 0, 0);
and you will remove the unnecessary use of eval as well.
--
Rob

Mar 2 '07 #4
Randy Webb wrote:
>
You start by removing code until you get a minimum case where it fails.
Scale it down to the minimum.
Done! There hardly is any code! I have uncommented the
alert on the eval string just prior to the eval().

Then you will find your error. It has a lot to do with the
format/eval'ing of the 'old' variable.

I beg to differ. It had no effect at all.

http://68.147.197.6/calgarydj/sampleA.htm

http://68.147.197.6/calgarydj/sampleB.htm
Mar 2 '07 #5
RobG wrote:
You have a div with id edate and an inferred global variable edate.
IE will create a global variable for the div since it is declared
before you try to assign a value to the inferred global edate.

When you try to assign a date object to edate, IE barfs.
Interesting hypothesis. I figured the HTML element id's
would have nothing to do with javascript variables
(different namespace).

I think I'm right here. The *edate* id was deleted and it
made no difference.

There are a
couple of solutions:
I'd suggest that where you have:

str = year + ',' + (month-1) + ',' + day + ',19,0,0'
old = s3 = 'new Date(' + str + ')'
edate = eval( old )
document.getElementById('title').innerHTML = edate.toString()
you should use (wrapped for posting):

document.getElementById('title').innerHTML =
new Date(year, (month-1), day, 19, 0, 0);
and you will remove the unnecessary use of eval as well.
Brilliant suggestion Rob! Much more elegant solution.

I should have thought of that myself! Got into a tunnel
vision mode there, focusing on the wrong thing.

Here it the updated one with your solution.

http://68.147.197.6/calgarydj/sampleC.htm

This still doesn't explain why sampleB did not work. It
should. I'm disappointed in IE7. They had a long time to
catch up to FF, and they still aren't there yet.

Cheers and many thanks,
Jim (from Canada)
Mar 2 '07 #6
RobG wrote:
>
You have a div with id edate and an inferred global variable edate.
IE will create a global variable for the div since it is declared
before you try to assign a value to the inferred global edate.
Actually Rob, you were right on this count too. I did more
testing on SampleB (instead of testing cached pages;-)).

I'm kind of amazed. It must have something to do with IE
document.all object. I don't think there should be overlap.

Cheers
Jim
Mar 2 '07 #7
VK
On Mar 2, 6:13 am, Diogenes <nos...@nospam.netwrote:
Interesting hypothesis. I figured the HTML element id's
would have nothing to do with javascript variables
(different namespace).
I think I'm right here.
Alas you are wrong. Read group FAQ:
<http://www.jibbering.com/faq/index.html#FAQ4_41>

For the minimum sample of RobG explanations and - respectively - your
own problems try this:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script>
function init() {
try {
myDiv = true;
}
catch(e) {
window.alert(e.message);
}
}
window.onload = init;
</script>
</head>

<body>
<div id="myDiv">myDiv</div>
</body>
</html>

Mar 2 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Bosconian | last post: by
4 posts views Thread by Bhavna | last post: by
4 posts views Thread by Carlos Moreno | last post: by
10 posts views Thread by Doug Robertson | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.