Language Basics JavaScript DHTML



Character Codes

var isNav = (navigator.appName == "Netscape")
var isNav4 = (isNav && parseInt(navigator.appVersion == 4))
function showCharCode() {
    if (isNav) {
        var theText = document.getSelection()
    } else {
        var theText = document.selection.createRange().text
    }
    if (theText) {
        document.forms[0].charCodeDisplay.value = theText.charCodeAt()
    } else {
        document.forms[0].charCodeDisplay.value = " "
    }
}
function showString(form) {
    form.result.value = String.fromCharCode(form.entry1.value,
form.entry2.value,form.entry3.value)
}
if (isNav4) {
    document.captureEvents(Event.MOUSEUP)
}
document.onmouseup = showCharCode



Capturing Character Codes

Select any of this text, and see the character code of the first character.


Character Code: