Connecting Tech Pros Worldwide Help | Site Map

Why is this happening? IE7 only error

  #1  
Old March 2nd, 2007, 01:55 AM
Diogenes
Guest
 
Posts: n/a
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
  #2  
Old March 2nd, 2007, 02:05 AM
Diogenes
Guest
 
Posts: n/a

re: Why is this happening? IE7 only error


Diogenes wrote:

Oh yeah, I forgot. Click on any calendar day to activate the
script.
Quote:
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
  #3  
Old March 2nd, 2007, 02:25 AM
Randy Webb
Guest
 
Posts: n/a

re: Why is this happening? IE7 only error


Diogenes said the following on 3/1/2007 8:47 PM:
Quote:
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/
  #4  
Old March 2nd, 2007, 02:45 AM
RobG
Guest
 
Posts: n/a

re: Why is this happening? IE7 only error


On Mar 2, 11:47 am, Diogenes <nos...@nospam.netwrote:
Quote:
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

  #5  
Old March 2nd, 2007, 02:45 AM
Diogenes
Guest
 
Posts: n/a

re: Why is this happening? IE7 only error


Randy Webb wrote:
Quote:
>
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
  #6  
Old March 2nd, 2007, 03:25 AM
Diogenes
Guest
 
Posts: n/a

re: Why is this happening? IE7 only error


RobG wrote:
Quote:
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
Quote:
couple of solutions:
Quote:
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)
  #7  
Old March 2nd, 2007, 03:35 AM
Diogenes
Guest
 
Posts: n/a

re: Why is this happening? IE7 only error


RobG wrote:
Quote:
>
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
  #8  
Old March 2nd, 2007, 05:55 AM
VK
Guest
 
Posts: n/a

re: Why is this happening? IE7 only error


On Mar 2, 6:13 am, Diogenes <nos...@nospam.netwrote:
Quote:
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>

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Safari Issue GinnTech answers 15 August 13th, 2008 02:35 AM
MS Expression Web not appearing on IE6 or less and I don't know why! robfrancis09 answers 1 July 30th, 2007 10:38 PM
IE7 Issue - Footer Jumping Up Page When Hovering Over TopNav Steve answers 19 July 12th, 2007 11:35 PM
Cannot modify cookies after HTTP headers have been sent gibble@gmail.com answers 5 May 10th, 2007 09:35 PM