Jump to content

Null Error With Ie8 - But Firefox No Problem - Why?


pinecone

Recommended Posts

Hi folks,I'm getting this java script error on IE8 but not on FireFox. :) IE8 says this;Line: 1Error: Object doesn't support this property or method'null' is null in this objectand this the line with the error: It's on the very first line character 6------------------------------------------------------------------$('message').addEvents({ 'keyup': function() { if (!chking) { chking = 1; clearTimeout(timeoutId); timeoutId = setTimeout('checkBad()', 2500); }-------------------------------------------------------------------Now im not familiar with the java coding, however can anyonespot the error?Let me know as soon as you have a chance,Thanks

Link to comment
Share on other sites

ok perhaps i didnt copy n paste enough of the code.IE has found another problem too. but here's the first 1 again.Error #1 'null' is null or not an object www.club.pinecone-crafts.com, line 911 character 6*************************************$('message').addEvents({ <<<<--- This is line with error) 'keyup': function() { if (!chking) { chking = 1; clearTimeout(timeoutId); timeoutId = setTimeout('checkBad()', 2500); } }, 'burn': function(B) { tmpstr = tmpstr.replace(/(\W)badword1(\W)/gi, "$2");tmpstr = tmpstr.replace(/(\W)badword2(\W)/gi, "$2");tmpstr = tmpstr.replace(/(\W)badword3(\W)/gi, "$2");tmpstr = tmpstr.replace(/(\W)badword4(\W)/gi, "$2");*********************************************************Error #2And the other error is:Object required www.club.pinecone-crafts.com, line 1131 character 9************************************************//alert("RESPONSE: " + req.responseText); this is the line with error ->> lastMsgId = document.getElementById('last_msg_id').value; //if (req.responseText == '1') { if (req.responseText != lastMsgId) { var req2 = null; if(window.XMLHttpRequest) { req2 = new XMLHttpRequest(); }**************************************************************What is the proper way to code the line as i have no clue..Thanks a bunch.Let me know as soon as as you have a chance.

Link to comment
Share on other sites

reason you are getting the null errors, is because there is no element, with an id reference of 'message' or 'last_msg_id" within the page. for example<div id="message">blah, blah, blah</div><div id="last_msg_id">blah, blah, blah</div>actually related code starts at this point:window.addEvent('domready', function(){ //mtxt = $('message'), logg = $('log'); mtxt = document.getElementById('message');

Link to comment
Share on other sites

one way to prevent a null error, is to see if object exists before running a procedure to look for a element, or retrieve a value from itreplace:mtxt = document.getElementById('message');with:if(document.getElementById("message")){mtxt = document.getElementById('message')}ANDreplace:lastMsgId = document.getElementById('last_msg_id').value;with:if(document.getElementById("last_msg_id")){lastMsgId = document.getElementById('last_msg_id').value;}

Link to comment
Share on other sites

one way to prevent a null error, is to see if object exists before running a procedure to look for a element, or retrieve a value from itreplace:mtxt = document.getElementById('message');with:if(document.getElementById("message")){mtxt = document.getElementById('message')}ANDreplace:lastMsgId = document.getElementById('last_msg_id').value;with:if(document.getElementById("last_msg_id")){lastMsgId = document.getElementById('last_msg_id').value;}
Thanks a lot dsonesuk! lolzOne last question if I may.Are you saying that the mtxt error line is all i need to replace, and whichwill repair that very first error on line 911?Or do i repair them both like you suggested?Sorry for being so dumb about this - I'm buggie-eyed!Thanks again
Link to comment
Share on other sites

it seems that the value for $('message') is not being found, also if you look at the code you will find commented out code(1) //mtxt = $('message'), logg = $('log');which seems to have been replaced with this(2) mtxt = document.getElementById('message');replacing $('message').addEvents( with mtxt.addEvents( should tie it in option (2) replacement.with this fixed, you still have the problem in that objects with id ref 'message' and 'last_msg_id' still do not exist within the page, so a null error will still be produced.looking at it again, because mtxt is referenced several time further down the page, the best option would be to prevvent these being processed until these object with these id reference are produced(where from i don't know).by adding if(document.getElementById("message") && document.getElementById("last_msg_id"))window.addEvent('domready', function(){ Edit: if(document.getElementById("message")) { //mtxt = $('message'), logg = $('log');code that goes on, and on, and on...... }}); (just above function checkBad)ANDreplace:lastMsgId = document.getElementById('last_msg_id').value;with:if(document.getElementById("last_msg_id")){lastMsgId = document.getElementById('last_msg_id').value;}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...