Connecting Tech Pros Worldwide Help | Site Map

Why is this happening? IE7 only error

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 2nd, 2007, 12:55 AM
Diogenes
Guest
 
Posts: n/a
Default 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

  #2  
Old March 2nd, 2007, 01:05 AM
Diogenes
Guest
 
Posts: n/a
Default 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, 01:25 AM
Randy Webb
Guest
 
Posts: n/a
Default 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, 01:45 AM
RobG
Guest
 
Posts: n/a
Default 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, 01:45 AM
Diogenes
Guest
 
Posts: n/a
Default 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, 02:25 AM
Diogenes
Guest
 
Posts: n/a
Default 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, 02:35 AM
Diogenes
Guest
 
Posts: n/a
Default 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, 04:55 AM
VK
Guest
 
Posts: n/a
Default 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>

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.