Yes, you have to use trial-and-error escaping of characters in the string - when you find a particular combination removes a linebreak, it may well cause another somewhere else, but it will remove any linebreaks caused by exactly that combination that you're using. You could also insert some vB codes, they tend to help as well.
Whoops! I forgot to build the return string. Replace the new code with this:
Code:
if (typeof(String.fromCharCode) == 'undefined') {
String.fromCharCode = function () {
if (arguments.length = 0) {
return "";
}
var charCodeChars = new Array(32),
returnString = "",
j;
charCodeChars[9] = '\t';
charCodeChars[13] = '\n';
charCodeChars.push(' ','!','"','#','$','%','',"'",'(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@');
charCodeChars.push('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\\',']','^','_','`');
charCodeChars.push('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','{','|','}','~');
for (j=0;arguments.length>j;j++) {
returnString += charCodeChars[arguments[j]];
}
return returnString;
}
}
...and let me know where that gets you.
edit: have to double-escape the backslash in the post; don't forget to fix the line-breakage. also: don't use i for an array iterator when you're using italics vB tags later!
Last edited by Choopernickel; 12-16-2003 at 05:18 PM..
That was indeed my next thought, glenn. I'll work on getting the whole deal integrated (including an Array.js file for any unsupported array methods), but until then, here's a copy with the push() method prototyped.
This script looks to be exactly what I need, but it doesn't seem to work exactly as described. Has it been tested under Firefox? The issues I'm running into are as follows:
1) No display of what is being typed in the status bar
2) Entering non-existing entries doesn't seem to work
3) Getting 'DOM2Event is not defined' errors, although it doesn't seem to be fatal.
4) Hitting backspace more times then the typed buffer causes the browser to go back to the previous page since backspace is a shortcut for back.
Are there work arounds for these issues?
...Izzy
---
Another thing... I have to agree with Glenngv re the timeout feature. At the very least, it seems way to quick. Having a way to turn this feature off or change the timeout value as Choopernickel suggested makes a lot of sense. Was any work done in this regard?
Last edited by izzyb; 01-17-2005 at 08:04 AM..
Reason: Another thing...
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
I haven't look into too much details but here are my thoughts:
1) Firefox has a default setting to NOT allow script to change status bar text (in Tools > Option > Web Features > [Advanced...] > Advanced Javascript Options).
2) Haven't look into this.
3) Try changing this: (and other similar codes)
Code:
TypeAheadCombo.prototype.elementFocus = function (evt) {
var theCombo;
if (evt && window.addEventListener) {
if (DOM2Event) {
var e = new DOM2Event(evt, window.event, this);
}
theCombo = e.target.combo;
}
...
}
to:
Code:
TypeAheadCombo.prototype.elementFocus = function (evt) {
var theCombo;
if (evt && window.addEventListener) {
if (typeof DOM2Event != "undefined") {
evt = new DOM2Event(evt, window.event, this);
}
theCombo = evt.target.combo;
}
...
}
I haven't tried the code change yet, but it looks right. I have changed the option for allowing javascript to change the status bar, but it doesn't seem to have fixed the problem.
I tried looking into the timeout issue, but my javascript knowledge is limited and I'm still trying to figure out exactly what makes it tick. (sorry for the pun I tried simply increasing the timeout values from 1600 and 2400 to 36000, but it doesn't seem to make a difference. I'm thinking the bug is elsewhere. If I understand correctly, these timeouts are in milliseconds, so this should be 16 and 24 seconds respectfully, but I doubt I'm seeing more then 1 or 2 seconds before a timeout. It'd be nice to just disable the feature. I'll take another look at it tomorrow and see if I can figure out how to do that.
The more critical problem for my current needs is regaining the ability to add new entries. I have to say I've learned a lot about javascript by stuying this code. With any luck, I'll figure this one out yet tonight...
Thanks again for getting back to me so quickly and for your work on this script in the first place
Looks like the code isn't running at all in firefox. The behaviour that I thought was the script looks to be built into firefox. It seems to do everything this script does, except the ability to add new entries, and the timeout seems really short.
That explains why my efforts to troubleshoot haven't responded as expected. I'm going to dig some more to see what the problem is.
I'm happy to say I finally have this script working.
Turned out to be a combination of problems, mostly in the perl script I was generating the page with. I wasn't calling the pageInit() script correctly and I neglected to give the form a name. The only real problems with this script were with the DOM2 calls. The solution Glenn suggested solves them.
I suggest the addition of something like this to help troubleshoot problems relating to forgetting to name your form.
Code:
if (this.element.form.name.length == 0 ) {
alert("The Form doesn't have a name.");
}
I added it to the constructor below the following lines:
Code:
// ASSOCIATION
this.element = anElement;
My Javascript skills are limited, so there may be a better way to do this.
Thanks again for the help Glenn. And thanks guys for the great script!