Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange cursor behavior 2

Status
Not open for further replies.

PulsarSL

Programmer
Jul 4, 2005
24
NO
Hey

In firefox, when I execute my script, the cursor changes to an arrow with an hourglass next to it, and never changes back to normal. Happens on two different computers. Does not happen in IE.

It's not an infinate loop as I have it print to screen right before the end of the functions and it successfully prints "execution complete".

What would cause this and how do I fix it?

Thx,

Pulsar
 
It would help to see your code.


It's hard to think outside the box when I'm trapped in a cubicle.
 
Sorry. It's an encryption program that uses one-time pads. It's kind of hard to follow the logic since it's undocumented. I'm porting it from visual basic. Basically, you call cipherText with your alphabet, clear text, key and a 0 or 1 telling whether you're decrypting or encrypting, respectively. It takes one character from the plaintext, one character from the key, looks up their positions in the supplied alphabet, adds together their values, does some math, spits out a numerical value, then looks this value up in the alphabet for an output character. Hope that's clear.

Thanks


function findOffset(alphabet, ch)
{
var newFindOffset = alphabet.indexOf(ch);
if (newFindOffset == -1) {
return -5;
} else {
return newFindOffset;
}
}



function findChr(alphabet, offset)
{
return alphabet.charAt(offset);
}



function cipherText(alphabet, inputtext, key, encrypt)
{
var understand = 0;
var ckeyl = 1;
var ciphertext = "";

for (i=0; i<= inputtext.length; i++) {
if (encrypt == 1) {
var opt = findOffset(alphabet, inputtext.charAt(i));
} else {
var oct = findOffset(alphabet, inputtext.charAt(i));
}

var oky = findOffset(alphabet, key.charAt(ckeyl));

if (opt == -5 || oky == -5 || oct == -5) {
alert("Error: not enough symbols");
//todo: terminate
}

if (encrypt == 1) {
var opo = (opt + oky) % alphabet.length;
} else {
var opo = (oct - oky + alphabet.length) % alphabet.length
}

var cop = findChr(alphabet, opo);

ciphertext = ciphertext + cop;

ckeyl++;

if (ckeyl > key.length && input.length > key.length) {
ckeyl=1;
if (encrypt == 1){
if (understood == 0){
alert("Wrap?");
//todo: fix this up, make it interactive
understood == 1;
}
}
}

}
document.write("execution complete");
return ciphertext;
}

function testCrypt(){
var textencrypt = cipherText('abcdefghijklmnopqrstuvwxyz','testing','thisiswhereyourkeygoes',1);
document.write(textencrypt);
}
 

<body onload="testCrypt()"> in the html file calls the testCrypt() function listed above.

Thanks
Pulsar
 
Hey guys,

Just so you know, there were a few little mistakes here and there (mostly with the math) that I've corrected. I won't post an updated version of the code unless you request it. The cursor problem is still there. The encryption/decryption code works as intended. I just ran through it and actually re-ported it straight from VB again, and the problem is still there. I added a return; statement to the testCrypt() function.

Pulsar
 
I wrote a simple test function to make sure I wasn't somehow stuck in an endless loop.


function checkCode() {
document.write("done.");
return;
}

I changed my onload to call this. Still get the hourglass arrow!

Why is this happening!!!
Please! I'm desperate for an answer!

Thanks

Pulsar
 
That's odd. If I take create a test harness which does what you've described, I see no problems in either IE 6 or Fx 1.5.0.3. What happens if you save my test harness and run it?

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
	<meta http-equiv="content-language" content="en">
	<title>Cursor test</title>
	<script type="text/javascript">
	<!--

		function checkCode() {
			document.write('done.');
			return;
		}

	//-->
	</script>
</head>

<body onload="checkCode();">
	<div>Some content...</div>
</body>
</html>

Do you still see the hourglass? If so, it could be a configuration issue with your Firefox.

If you don't it could be something else on your page (as I mentioned above, do you set the cursor anywhere? Maybe in CSS or other external JS file?)

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
First, I'd like to say thanks for all the help so far.

I copied your code into a fresh HTML document and loaded it up on a different computer, and I still get the hourglass cursor. I really have no clue why this is happening. If I go to something like javascriptsource.com and look at some of their JS demos, I do not get this cursor.

I don't think it's my firefox config., as this is my second computer I tried it on, and I also got my friend to load it off my local webserver. He had the same hourglass problem.

This perplexes me. It can't be CSS or a cursor change because your demo still caused the problem (and I didn't use a cursor change script or any CSS in my program).

I'm running Firefox 1.5.0.3. I guess I'll try a clean firefox reinstall and see what happens.

Still works swimmingly in IE.

Pulsar
 
>document.write("execution complete");

Or other kind of construction is actually no good. It writes over the page. If you really want to test the effect, add a document.close() after it. But, you will see the result is no satisfactory, the chain calls of function will be lost.
[tt]
//and other similar places
document.write("execution complete");
[red]document.close();[/red]
[/tt]
Moz's hourglass is waiting for the document so opened to close!

If you want to display stage of progress on the screen, just make a div in the body.
[tt]
<div id="divid"></div>
[/tt]
and in the place of every document.write use innerHTML to write to it.
[tt]
document.getElementById("divid").innerHTML+="<p>execution complete</p>"
[/tt]
 
THANK YOU tsuji and Dan. document.close() fixed it.

It is very strange that in yours it did not exhibit similar results.

Thanks!!

Pulsar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top