473,396 Members | 1,892 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,396 software developers and data experts.

function breaks when run too fast?

Hi,

I have a pretty wierd situation. I have a javascript function that
runs when I submit a page. The onsubmit code does quite a bit - it
goes through a big textarea and replaces tabs with spaces,
inserts/removes line breaks...it uses regular expressions to convert
textarea content into somethign that can be sent to a mainframe
application.

Here's the problem: Sometimes special characters are pasted into the
text area from Word. Then, the submit code seems to go wrong - it
jumbles the content and some of the data is lost. I started adding
alerts in various places in the code to try and see where it was going
wrong. But it seems that by placing the alerts in the function, it
slows it down... and the error goes away!

It seems as though the code is going too fast and getting confused.
....but that doesn't really make sense to me. Has anyone ever
experienced illogical breaks like this? Any suggestions?

Thanks in advance!
Jul 23 '05 #1
7 1869
John Angel wrote:
I have a pretty wierd situation. I have a javascript function that
runs when I submit a page. The onsubmit code does quite a bit [...]
Here's the problem: Sometimes special characters are pasted into the
text area from Word. Then, the submit code seems to go wrong - it
jumbles the content and some of the data is lost. [...]


URL?
PointedEars
Jul 23 '05 #2
Thomas 'PointedEars' Lahn <Po*********@nurfuerspam.de> wrote in message news:<41**************@PointedEars.de>...
John Angel wrote:
I have a pretty wierd situation. I have a javascript function that
runs when I submit a page. The onsubmit code does quite a bit [...]
Here's the problem: Sometimes special characters are pasted into the
text area from Word. Then, the submit code seems to go wrong - it
jumbles the content and some of the data is lost. [...]


URL?
PointedEars


Unfortunately, this is part of a large, internal web application. I
guess I'm just wondering whether or not it's possible for javascript
(In IE6/xp) to get "ahead of itself" as it seems to.
Jul 23 '05 #3
Thomas 'PointedEars' Lahn <Po*********@nurfuerspam.de> wrote in message news:<41**************@PointedEars.de>...
John Angel wrote:
I have a pretty wierd situation. I have a javascript function that
runs when I submit a page. The onsubmit code does quite a bit [...]
Here's the problem: Sometimes special characters are pasted into the
text area from Word. Then, the submit code seems to go wrong - it
jumbles the content and some of the data is lost. [...]


URL?
PointedEars


Unfortunately, this is part of a large, internal web application. I
guess I'm just wondering whether or not it's possible for javascript
(In IE6/xp) to get "ahead of itself" as it seems to.
Jul 23 '05 #4
rf
John Angel
Unfortunately, this is part of a large, internal web application. I
guess I'm just wondering whether or not it's possible for javascript
(In IE6/xp) to get "ahead of itself" as it seems to.


When I drive my car too fast it rattles. Can you tell me what is wrong?

Oh, you want to see the car? Well, no, unfortunately you cant. It's locked
in the garage.

--
Cheers
Richard.

Jul 23 '05 #5
Lee
John Angel said:
[...]
But it seems that by placing the alerts in the function, it
slows it down... and the error goes away!


Yes, that happens. Sometimes it seems to be a bug in the
browser that requires a change in state from code execution
to event processing before a change takes place. Other cases
can be explained by the fact that some method calls return
before the task (opening a window, for example) is completely
finished.

It's likely that at least one person reading this has
experienced your problem, but we would need to see an example.

We don't need to see the whole project.
Create a small test case that demonstrates the problem.
I'm particularly interested in seeing how you invoke the code
that's causing trouble.

Jul 23 '05 #6
John Angel wrote:
Hi,

I have a pretty wierd situation. I have a javascript function that
runs when I submit a page. The onsubmit code does quite a bit - it
goes through a big textarea and replaces tabs with spaces,
inserts/removes line breaks...it uses regular expressions to convert
textarea content into somethign that can be sent to a mainframe
application.

Here's the problem: Sometimes special characters are pasted into the
text area from Word. Then, the submit code seems to go wrong - it
jumbles the content and some of the data is lost. I started adding
alerts in various places in the code to try and see where it was going
wrong. But it seems that by placing the alerts in the function, it
slows it down... and the error goes away!
That is known as a "heisenbug":
<url: http://info.astrian.net/jargon/terms/h/heisenbug.html />
<url: http://c2.com/cgi/wiki?HeisenBug />
<url: http://www.wordspy.com/words/heisenbug.asp />
It seems as though the code is going too fast and getting confused.
...but that doesn't really make sense to me. Has anyone ever
experienced illogical breaks like this? Any suggestions?


It seems unlikely that the code is "going too fast". It is, as Lee pointed
out, more likely an issue with the way you invoke your code.

Also, given the fact that you mention "special characters", I'd ensure
your code is either unicode compatible, or can deal with unicode
characters properly, either by rejecting them outright, or converting them
into something that you can actually submit (by modding the character code
with 256 for example).

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #7
John Angel wrote:
Thomas 'PointedEars' Lahn <Po*********@nurfuerspam.de> wrote [...]:
John Angel wrote:
[...] I have a javascript function that runs when I submit a page.
The onsubmit code does quite a bit [...] Here's the problem:
Sometimes special characters are pasted into the text area from Word.
Then, the submit code seems to go wrong - it jumbles the content and
some of the data is lost. [...]


URL?
[...]


Unfortunately, this is part of a large, internal web application. I guess
I'm just wondering whether or not it's possible for javascript (In
IE6/xp) to get "ahead of itself" as it seems to.


You could post relevant snippets of your code as well.
PointedEars

P.S.
Please read <http://netmeister.org/news/learn2quote.html> regarding
the attribution _line_ and other recommended quoting practices.
Jul 23 '05 #8

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

Similar topics

3
by: Zac Panepucci | last post by:
Hello There, I am using the following constructs to parse named arguments: function whatever() { if (this.yo) { if(this.yo=='man') alert('wuzup'); else
2
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
41
by: Materialised | last post by:
I am writing a simple function to initialise 3 variables to pesudo random numbers. I have a function which is as follows int randomise( int x, int y, intz) { srand((unsigned)time(NULL)); x...
6
by: Alexis Nikichine | last post by:
Hello, Today, I have a function: function f() { } and am looking for a way of distinguishing, from inside f, whether it
10
by: Evie | last post by:
I understand that when a switch statement is used without breaks, the code continues executing even after a matching case is found. Why, though, are subsequent cases not evaluated? I wrote a...
21
by: Hallvard B Furuseth | last post by:
Is the code below valid? Generally a value must be accessed through the same type it was stored as, but there is an exception for data stored through a character type. I'm not sure if that...
17
by: DanielJohnson | last post by:
how to use the combination function in python ? For example 9 choose 2 (written as 9C2) = 9!/7!*2!=36 Please help, I couldnt find the function through help.
19
by: xdevel | last post by:
Hi, I know there are in stdlib.h many functions to perform conversion from string to int, double ecc. but I don't understand if there are some standards function to perform conversion from...
11
by: Daniel T. | last post by:
The function below does exactly what I want it to (there is a main to test it as well.) However, I'm curious about ideas of making it better. Anyone interested in critiquing it? void formatText(...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.