473,395 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Bizarre JS bug involving brackets (IE6/SP2)

Afternoon,

I have just finished fixing one of my scripts after it started
generating odd errors on IE6 on WinXP Service Pack 2.

For info, the IE Version is:
6.0.2900.2180.xpsp_sp2_rtm.040803-2158
I have done all the Windows critical updates. I haven't
managed to replicate the behaviour in any other browser.
I have tested the faulty version in Netscape 4.7x, IE 5
and Opera 7 and it works fine in all three.

The two files are here:
http://www.exeter.ac.uk/cimt/mepres/...i1/bk8_1i2.htm (works)
http://www.exeter.ac.uk/cimt/mepres/...1i2_faulty.htm
(faulty)

There is only *one* difference between the two files in line 29.

To make it work, I had to change:
inputbox.value = numq+ag-cw-cc;
to:
inputbox.value = numq+(ag)-(cw)-(cc);

In the faulty version, the page generates two errors while
downloading:
(i) Line 33 Char 16 Expected ')'
(ii) Line 1076 Char 19 Expected ';'

Line 33 is "pc = ((cc*100)+extra)/numq;"
Line 1076 is "tands = 'Y8 Unit '+unit+' Section '+section;"

In these lines, chars 16 and 19 are both "+" signs.

Now I cannot work out for the life of me what the problem is!
Anyone have any ideas?

Al


Jul 23 '05 #1
8 1533


Al Reynolds wrote:

I have just finished fixing one of my scripts after it started
generating odd errors on IE6 on WinXP Service Pack 2.

For info, the IE Version is:
6.0.2900.2180.xpsp_sp2_rtm.040803-2158 http://www.exeter.ac.uk/cimt/mepres/...1i2_faulty.htm
(faulty)


One thing is for sure, JavaScript comments are not done with
<!-- comment -->
as you seem to think and make use of in the script section on that page
but rather need to be written as
// comment
for a one line comment or as
/* comment
comment
*/
if you need several lines.
Try taking those
<!-- comment -->
lines out and you are improving your chances that browsers do not report
syntax errors.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:41**********************@newsread4.arcor-online.net...

One thing is for sure, JavaScript comments are not done with
<!-- comment -->
as you seem to think and make use of in the script section on that page
but rather need to be written as
// comment
for a one line comment or as
/* comment
comment
*/
if you need several lines.
Try taking those
<!-- comment -->
lines out and you are improving your chances that browsers do not report
syntax errors.


So you don't know the answer to the question then? I've already
solved the problem - the details were in my original post - so the
format I used for my comments wasn't part of the problem. I'll
be sure to use the correct commenting technique in the future.

Al
Jul 23 '05 #3
On Wed, 29 Sep 2004 16:23:09 +0100, Al Reynolds <aj******@bat400.com>
wrote:

[snip]
Now I cannot work out for the life of me what the problem is!
Anyone have any ideas?


It would be nice to know how to replicate the problem. Using the system
correctly doesn't produce errors, and it's too late for me to experiment,
so what does?

A couple of quick comments:

1) Validate your pages.
2) Why are all but one of your variables global? That's asking for trouble.
3) Mind explaining the purpose of those eval calls in the Calculate
function?

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4
On Wed, 29 Sep 2004 23:04:19 GMT, Michael Winter
<M.******@blueyonder.co.invalid> wrote:

[snip]
A couple of quick comments:


Forgot an important one: making a feedback form dependent upon Javascript
is a *very* bad idea. Using a pop-up is even worse. Contact forms
shouldn't require anything from the user agent other than the ability to
parse HTML. They can use more, by all means, but they shouldn't require
more.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #5
"Al Reynolds" <aj******@bat400.com> wrote in message news:<cj**********@south.jnrs.ja.net>...
I've already
solved the problem - the details were in my original post - so the
format I used for my comments wasn't part of the problem.

The last lines of the original post read in my newsreader:
"Now I cannot work out for the life of me what the problem is!
Anyone have any ideas?"
Seems like you were looking for any reason the script might be in
error and it doesn't read like all the problems were solve at the
time.
Hard to believe there is a difference in these lines:

To make it work, I had to change:
inputbox.value = numq+ag-cw-cc;
to:
inputbox.value = numq+(ag)-(cw)-(cc);
I'd assume the real problem code was somewhere else and this change
just happened to avoid the problem.

Robert
Jul 23 '05 #6
"Robert" <rc*******@my-deja.com> wrote in message
news:c6**************************@posting.google.c om...
Hard to believe there is a difference in these lines:

To make it work, I had to change:
inputbox.value = numq+ag-cw-cc;
to:
inputbox.value = numq+(ag)-(cw)-(cc);
I'd assume the real problem code was somewhere else and this change
just happened to avoid the problem.


The two files are *identical* apart from this line.

Al
Jul 23 '05 #7

"Al Reynolds" <aj******@bat400.com> wrote in message
news:cj**********@south.jnrs.ja.net...
"Robert" <rc*******@my-deja.com> wrote in message
news:c6**************************@posting.google.c om...
Hard to believe there is a difference in these lines:

To make it work, I had to change:
inputbox.value = numq+ag-cw-cc;
to:
inputbox.value = numq+(ag)-(cw)-(cc);
I'd assume the real problem code was somewhere else and this change
just happened to avoid the problem.
The two files are *identical* apart from this line.

Al


I should have added: so you're probably right. But I can't
work out why. There are no references to any of these
variables anywhere else other than where they should be.

Al

Jul 23 '05 #8
"Michael Winter" <M.******@blueyonder.co.invalid> wrote:
It would be nice to know how to replicate the problem.
If I get time, I will take out other code until the error ceases
appearing. I'll let you know what I find.
A couple of quick comments:
1) Validate your pages.
One of the problems with writing code that will work in NS4.7x
without excessive use of multiple code for different browsers is
that it doesn't do well on most validation tests. But it's a fair point.
2) Why are all but one of your variables global? That's asking for
trouble.
Indeed. As someone who learnt to program in the strongly-typed
structured environment demanded by Modula-2, almost everything
involved in Javascript seems like "asking for trouble" to me. As a
result I use naming conventions to try and avoid side-effects.
3) Mind explaining the purpose of those eval calls in the Calculate
function?
Probably a remnant of some NS4.7x compatible code that didn't
have a constant inside the brackets. These things happen when code
is developed in an "organic" way.
Forgot an important one: making a feedback form dependent upon Javascript
is a *very* bad idea. Using a pop-up is even worse. Contact forms
shouldn't require anything from the user agent other than the ability to
parse HTML. They can use more, by all means, but they shouldn't require
more.


Another fair point. Since the entire page requires javascript to
operate, I have used it for the feedback mechanism. The few
people who can't use the page because of not having Javascript
turned on (but can't work out why) could use the email link to
request some assistance.

Please don't ask me why I'm writing code that still work in NS4.7x.

Al
Jul 23 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: The Plankmeister | last post by:
This really is very strange... Have a look at this: http://www.plankmeister.org.uk/new/index.html in IE6. When it loads, the top section is blank. If you mouseover anything in the menu half of...
5
by: Griff | last post by:
We have a web application that users can use by first authenticating themselves via a secure connection (HTTPS/SSL). If one goes directly to that secure page then one can log in successfully...
6
by: mark | r | last post by:
how do i automatically trigger functions like displaydate() in SP2 without getting that annoying security error. i use things like these almost every time on sites (see www.sicl.co.uk for my...
8
by: Al Reynolds | last post by:
Afternoon, In an earlier thread (http://tinyurl.com/5v4aa), I described a problem I was having which was rather bizarrely solved by changing the line: "inputbox.value = numq+ag-cw-cc;" to:...
6
by: rob | last post by:
Hi I'm trying to create a "roll-up" effect when a window loses focus and then "roll-down" when it regains focus. This statement works properly with every browser I can get my hands on EXCEPT...
0
by: ATS | last post by:
PRB: Can not get UserControl/HTML/OBJECT to work on XP/SP2/IIS/IE6 Please help, I can not get my UserControl to work from a simple OBJECT tag in a simple HTML web page on Windows XP with SP2...
1
by: Oleg Konovalov | last post by:
Hi, I am using IE6.0.2900.2180.xpsp_sp2_grd.050301-1519 with all latest XP Pro patches and for some reason it doesn't display JavaScript errors which other users can see in exactly same...
102
by: BoogieWithStu22 | last post by:
I am running into a problem with a web page I have created when viewing it in IE6 on some machines. The page has a database lookup. The user enters an account name or number and clicks a lookup...
36
by: sheldonlg | last post by:
Here is an app: www.sheldonlg.com/JSstops.htm It passes strict W3C validation. **In IE6**, if you click on the plus, a sub-table appears. Click on the plus from the subtable and nothing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.