Posts: 319
Threads: 68
Joined: Mar 2005
How do you get the ascii code for a letter in javascript. Or can you at all?
his world has been connected...
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless
Posts: 500
Threads: 7
Joined: Jun 2005
Here is a way that I found through Google (several times):
http://javascript.internet.com/miscellan...-code.html
Here is a script to input a letter and return its ASCII code (using the script contained in the page above):
[syntax="JavaScript (ECMAScript)"]var userChar = prompt("Enter a character: ","");
var character = userChar.substring(0,1);
var code = userChar.charCodeAt(0);
var msg = "The ASCII Decimal Key Code for the \""+character+"\" character is "+code+".";
alert(msg);[/syntax]
It automatically truncates the user input to just the first character.
Beware of using the Alt+xxxx or Alt+xxx sequences to render a character not on the keyboard. Alt+128 (Ã) renders 199 (the Unicode value, not ASCII) whereas Alt+0128 (â¬) renders 8364 (once again, the Unicode value rather than ASCII). In short, JavaScript isn't good for automatically doing this. I recommend using a table or creating your own string with ASCII characters (or something like that).
Edit: Edited to note that the proper name for JavaScript is ECMAScript.
974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Posts: 319
Threads: 68
Joined: Mar 2005
Speaking of javascript is external javascrip supported in FireFox
his world has been connected...
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless
Posts: 2,404
Threads: 153
Joined: Jan 2005
Should be... Test it?
:wink:
Kevin (
x.t.r.GRAPHICS)
Posts: 319
Threads: 68
Joined: Mar 2005
what about javascripts that create popups?
his world has been connected...
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless
Posts: 500
Threads: 7
Joined: Jun 2005
As far as I know, Firefox supports window.open() popups as long as they are allowed (e.g. run locally or something in the JS code doesn't trigger FF's safety sensors). I honestly don't do too much with JS. I'm more into console programming than Web scripting. In fact, this is my first time in nearly 2 months. Before that, it was about 7 months (since now).
Edit: Unless you are referring to window.prompt() or window.alert() popups. . . These are allowed by default.
974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Posts: 2,404
Threads: 153
Joined: Jan 2005
FF does more with JS then IE,... or at least my IE can't do some of it, like document.URL fails to return anything past ?... Which FF does fine...
And may I ask,. Make FF your default browser, so when you save the .html, you can click on it and quickly test it offline.... Just saying,.. testing is faster than waiting for us to reply.... tho when all else fails, that's a good time to ask.. :wink:
Kevin (
x.t.r.GRAPHICS)
Posts: 319
Threads: 68
Joined: Mar 2005
yah i do test offline but i must've had some errors in my code so thats why i asked before i struggled to much to debug
his world has been connected...
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless
Posts: 2,404
Threads: 153
Joined: Jan 2005
Call me hard, but you can learn a lot that way,.. :wink: ... But yeah, you got a point...
Kevin (
x.t.r.GRAPHICS)
Posts: 500
Threads: 7
Joined: Jun 2005
Quote:Call me hard, but you can learn a lot that way,.. :wink: ... But yeah, you got a point...
I agree. I helped so many people in my QBasic class that most of them are lost in the "Introduction to C++" course at my high school. Some people didn't even have help from other students in QBasic and they forget one of the most crucial parts in C++: a semicolon, or ';', at the end of a statement, just like in JavaScript (the basic structures, such as for() loops, while() loops and the do-while() loops are the same, though C++ requires explicit definitions of variables' data types).
I journeyed through C++ alone through the summer, using Dev-C++ as my IDE. Because of that, I can help others with the error messages rendered on their computers. :-) The idea is to learn what you can and when you get stuck, try to debug yourself. If those fail, ask for help.
974277320612072617420666C61696C21 (Hexadecimal for those who don't know)