473,796 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1886
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*********@nu rfuerspam.de> wrote in message news:<41******* *******@Pointed Ears.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*********@nu rfuerspam.de> wrote in message news:<41******* *******@Pointed Ears.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*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #7
John Angel wrote:
Thomas 'PointedEars' Lahn <Po*********@nu rfuerspam.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.htm l> 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
1511
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
9803
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 in a link. that function can have parameters for URL and window name passed to it. This works peachy in Firefox (1.0). With IE 6 (6.0.29) on two separate computers, I get an "onject expected" error. Going to the MS-based debugger just tells me...
41
3832
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 = rand(); y = rand();
6
1699
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
12328
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 program to demonstrate how a switch without breaks behaves vs. how I expected it to behave. The code includes: (1) a switch statement with breaks (2) the if/else statements that have the same results as (1) (3) a switch statement without breaks...
21
3908
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 applies in this case though: #include <limits.h> unsigned foo(void) { static const union { unsigned char str;
17
8100
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
1556
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 int, double ecc to string Thanks.
11
1783
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( const string& in, int charsPerLine, int lines, vector< string >& out ) { out.resize( 1 ); out = ""; int prev = 0;
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.