...

View Full Version : Help with Firefox error: "... has no properties"



Uncle_Billy
03-16-2005, 08:04 PM
Hello all.
I have a problem with this script in Firefox(Win, Mac) - yet it runs just fine in IE Win and Safari. The script:


function do_output_cb(out_str) {
document.getElementById("outtext").innerHTML = out_str;
}
function do_output() {
var chars;

var e = window.event;
var c = String.fromCharCode(e.keyCode).toLowerCase();

chars = document.getElementById("text").value;

chars = chars + c;
if (chars != "")
{
x_arrayCheck(chars, do_output_cb);
}
else
{
document.getElementById("outtext").innerHTML = "";
}
}

The error being thrown says "Error: e has no properties," and i'm guessing it happens on the line in bold. Is this one of those DOM support issues?
Thanks in advance!

vwphillips
03-16-2005, 08:18 PM
try playing with



<script language="JavaScript" type="text/javascript">
<!--

function vtbKeyPress(e){
if (!document.all){
KeyCode=e.which; // Demo Only
}
else {
KeyCode=event.keyCode; // Demo Only
}
alert(KeyCode)
}

if (!document.all){
document.captureEvents(Event.KEYDOWN)
}

document.onkeypress=vtbKeyPress


//-->
</script>

Uncle_Billy
03-16-2005, 09:13 PM
ehh, thanks for that. I'm not having too much luck with that, either -- now it throws the same error for IE! If I could just understand what was happening...
I'm trying to catch keyboard input from a text field called "text," and throw it to a function called x_arrayCheck(). I'm a javascript newb, btw :-)
Thanks!

vwphillips
03-16-2005, 09:24 PM
not much time so crude



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<title></title>
</head>

<body>
<script language="JavaScript" type="text/javascript">
<!--
var pass;

function vtbKeyPress(e){
if (!pass){return; }
if (!document.all){
KeyCode=e.which; // Demo Only
}
else {
KeyCode=event.keyCode; // Demo Only
}
alert(KeyCode)
x_arrayCheck(String.fromCharCode(KeyCode));
}

if (!document.all){
document.captureEvents(Event.KEYDOWN)
}

document.onkeypress=vtbKeyPress

function x_arrayCheck(kcs){
alert(kcs)
}
//-->
</script>

<input name="text" size="10" onfocus="javascript:pass=1;" onblur="javascript:pass=null;" >
</body>

</html>



tested in Ie but prob with Moz onblur of alert

j23orz
01-12-2008, 03:21 AM
I am having the same type of issue. However, I have been educated that the document.all propery does not work with Firefox. Firefox does have an Error tool that will tell you exactly where the error lies.
Tools ----> Error Console.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum