Ok, I was coding some javascript for an intranet application and I kept getting this error: “Object doesn’t support this property or method”. I was just using a button with an onclick event to call a function to close a record through a AJAX call. I reduced the function down to just an alert(”hello”) and still was getting this error.
Stepping forward to the issue, I was calling a function, “closeRec(var1,var2)” and had a form with an ‘id=”closeRec”. For some reason, maybe a good reason, in IE this causes this very generic ERROR. This is a case sensitive issue as ‘id=”CloseRec” does not initiate the error.
If you have a good explanation for this error “Object doesn’t support this property or method” in IE please respond. (I Didn’t try FireFox)
66 comments ↓
Wow, thanks for this. My brain was melding down trying to figure out this error. Firefox does not create this error if a variable/Function whatever has the same name as a HTML ID
I had the same problem:
The error is generated on the second row in the example above. Changing the fromDate var to something else get rid of the error.
Thanks for the help!
If you think about the world as objects then this error is perfectly valid.
For example, if I create a class ‘myClass’ with the code:
function myClass() {
.. constructor code
}
Then I can create an instance of that class with var objectInstance = new myClass();
It wouldn’t be good to start using myClass as a variable when it’s also actually a class!
So if you call your function closeRec() you’ve declared it as an object awaiting properties, methods etc.
If you then try and impede on closeRec’s memory allocation by further defining it as something else you’d perhaps want the parser to chuck it out!
So perhaps IE is promoting good practises
IE ‘helpfully’ creates a window-level (i.e., global) variable for forms on the page using their id attribute (so a form with an id of ’someForm’ can be referenced automatically as ‘window.someForm’ or just ’someForm’).
By giving a form further down the page the same id as your function, you basically redefined closeRec to be the form (global var closeRec no longer pointed at your function, it pointed at the form).
The error method isn’t really helpful, but it’s IE’s way of saying “you’re trying to make this object do something it can’t do.” Which makes sense, because you were trying to pass args to the form and execute it.
hello, i am using DHTML window and a ajax request for calculation, both use the same window object that’s why it produce “Object doesn’t support this property or method” error. How i can solve this problem.
John
Hi all,
Iam getting the same error “Obj doesn’t support this property or method”. I’ve noticed what Chris has mentioned,. Chris, i’ve changed all the variable names and even the id’s. But still when i click the button, it doesnt getting the input which i’ve included in the javascript function. Here is the code which iam trying to do….. hope u will get a better understanding if u go through the below code…..
function Like(arg)
{
var a=document.getElementById(arg.id)
var b =document.getElementById(”txtQuerySyntax”)
var c =document.getElementById(”txtActualSyntax”)
b.value += ‘ ‘ + a.value + ‘ ‘ + ‘%’ + ‘ ‘
c.value += ‘ ‘ + a.value + ‘ ‘ + ‘%’ + ‘ ‘
}
Iam trying to do the ‘LIKE’ operator in a QueryBuilder module….. Kindly help me if somebody gets the idea…
with regards
Paul
I was getting the same issue with: onclick=”foo” but it worked without error when I changed it to, onclick=”foo()” since it is calling a function.
Kudos to Scotsman for working this one out!
Hope it helps!
iLeafy
I was getting the same issue with: onclick=”foo” but it worked without error when I changed it to, onclick=”foo()” since it is calling a function.
Kudos to Scotsman for working this one out!
Hope it helps!
iLeafy
i was getting this painintheass error when using
minVal = document.getElementById(”someSpan”).innerHTML;
so i realized i didn’t include “var” before my minVal variable ¬¬’
im used to work with php, with no var declarations. so if youre like me, you better watch out your js declarations
ya encontre la solucion es muy simple en fire fox ver 3 no tiene ningun problema con la estructura DOM, como dice uno de los patas por aqui IE reconoce jerarquiras
Funciona para Firefox 3 sin problemas, pero no para IE
divrespuesta = document.getElementById(’divrespuesta’);
Funciona para Firefox 3 y para IE sin problemas
var divrespuesta = document.getElementById(’divrespuesta’);
Soy de Puno Peru y les pongo en español para q sufran un poco gringos pendejos…
Hi, I was getting the same error when using javascript to control a flash jukebox (see: http://www.jeroenwijering.com/?item=JW_FLV_Media_Player).
I had the jukebox hidden and was using some custom-made buttons to control it through javascript. It worked fine in Firefox and Safari, but in IE (6 & 7) it didn’t. Turns out that it was the “visibility:hidden;” css declaration on the that contained the jukebox that was causing the trouble. I set it to “visibility:visible;” and all was well. It seems that IE can’t run javascript on things that are within hidden elements.
That should read:
..declaration on the <div> that contained…
Translating Neilmas’s post:
I’ve found the solution is very simple. In Firefox 3, there was no problem with the DOM structure, but as one of the people here said, IE knows heirarchies.
This works in FireFox 3 without problems, but not for IE:
divrespuesta = document.getElementById(’divrespuesta’);
This works in Firefox 3 and in IE without problems:
var divrespuesta = document.getElementById(’divrespuesta’);
I’m from Puno, Peru…
(Translated,)
Jonathan
http://JonathansCorner.com/
I still have the problem, how can I fix it?
So should I run Firefox newest version
I’ve had the same problem but I’ve fixed with include “var” before var declaration … thanks Erebus
Hi! I’m facing the same problem, but can’t figure it out what’s wrong with my script. Javascript is pretty new to me so if someone could give me a hand I would appreciate it
So my script is “showhide”, basically it shows content onclick and another click it will hide the content. For some reason there is one content (mini calendar) which won’t show. The error occurs when using IE (not only ie6, but ie7 too), but works on firefox 3 (haven’t tried other versions)
my script is:
function HideContent(d) {
document.getElementById(d).style.display = “none”;
}
function ShowContent(d) {
document.getElementById(d).style.display = “block”;
}
function ReverseDisplay(d) {
if(document.getElementById(d).style.display == “none”) { document.getElementById(d).style.display = “block”; }
else { document.getElementById(d).style.display = “none”; }
}
thanks!
Your script works for me, here is my code I used.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script type="text/javascript" >
function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}
function ReverseDisplay(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
</script>
<style>
.click {
text-decoration:underline;
font-size:10px;
font-family:Georgia, "Times New Roman", Times, serif;
cursor:pointer;
}
</style>
<body>
<span class="click" onclick="HideContent('ONE')" >HIDE ONE</span> <span class="click" onclick="ShowContent('ONE')" >SHOW ONE</span> <span class="click" onclick="ReverseDisplay('ONE')" >REVERSE ONE</span>
<div id="ONE" style="display:block;">THis is some text<br />For Display"</div>
</body>
</html>
This is stupid error. For my case, it’s simply name conflict.
The function name cannot be the same as the object (button) name.
You get error when:
<input type="button" value="clear" onclick=clear() name="clear_btn2">
No error:
<input type="button" value="clear" onclick=clearTextArea() name="clear_btn2">
@erebus: I too was forgetting “var” before declaring my variable. PHP – JavaScript – PHP – JavaScript. Darned protocols!
Hi all
I have the same error, but my problem goes a bit far away… the app was working till some point in the past week… suddendly (suppose after any installation) the app down…
any help?
tks
Wanted a menu to fade in, so I did this:
$$(’body’)[0].appendChild(Builder.node(’div’,{id:’top’}, [...]).hide());
Which gave this error. Simple fix is to just do:
$$(’body’)[0].appendChild(Builder.node(’div’,{id:’top’}, [...]));
$(’top’).hide();
And it works!
Anyone have any suggestions as to why this script is not compatable with IE? (works in Firefox). I get both an Invalid argument error and an Object doesn’t support this property or method error. Thanks
Username:
Password:
Guys, I don’t know ANYTHING about what everbody is talking about, but I need some help from you experts. I’m trying to open my email on the hotmail account and at the bottom of the window i get: object doesn’t support this property or action. I have no idea what this means or how to fix it. I’ve read your solutions but being ignorant in the matter, I don’t know what to do. Can someone explain in plain English or Spanish. Gracias.
I was facing the same problem while using the active X control. After long time spending I found that this problem is due to cashing in the IE. On clearing the cashe, it start working fine without any issue.
I am also getting the same error in IE but not in Firefox. I’ve tried the suggestions about with no success. Can someone help? I am trying to take a person to the next item when they click on a next button. Thank you!
My javascript code:
function onClick nextItem()
{
if (i0)
{
i–;
display();
}
}
I am getting an “object doesn’t support this property or method” error when trying to show the text from a combo box item in a tooltip. Sometimes the items in the combo box are too long to see, so in order to see the full string, I am trying to show a tool tip with the full string when the item is selected (clicked). This code works in IE7 but not IE6 (I have to develop for IE6). The error occurs on the line containing:
var selected_text = selected.options[selected.selectedIndex].text;
Could someone please help me with a work around for IE6?
So far I have:
Functions…
function getTip()
{
var selected = document.getElementById(”selected”);
var selected_text = selected.options[selected.selectedIndex].text;
showTip(selected_text);
return;
}
function showTip(selected_text){
document.form.selected_item.title=selected_text;
return;
}
Combo Box…
This is the combo box from my previous code, think my post was too big
Combo Box…
select name=”selected_item” id=”selected” onClick=getTip(); title=showTip(); style=’width:300px;height:150px’ multiple
For mine, the system is working for 2-3 times and then it is throwing this error of object doesn’e support…..
Means when i start the applicaiton works fine but after a certain 2-3 times clicking it throws this error.
Please help me out in this
thank you very much for sharing this
I got the same error when i submit the form in the Struts… Thanks in advance…
document.forms[0].action=”AuthTxn.do”;
document.forms[0].submit();
I’m getting a similar error. This is the portion that’s causing the error.
this.headers = new Hash;
var thead = $(this.table.getElementsByTagName(’thead’)[0]);
$each(thead.getElementsByTagName(’tr’)[0].getElementsByTagName(’th’), function( header, index ) {
var header = $(header);
this.headers.set( header.getText(), { column: index } );
header.addEvent( ‘mousedown’, function(evt){
var evt = new Event(evt);
this.sort_by_header( evt.target.getText() );
}.bind( this ) );
}.bind( this ) );
@neilmas:
No traigas tu mierda aqui. Si quieras ayudar, ayuda! Si, no, no diga tales cosas. “Gringos pendejos…” Para mi, tu eres el latino pendejo.
Hi there, thanks for these comments – you are correct that if you call a javascript function name the same name as a div id then it goes balls up in IE.
I got the error because i named some functions in javascript the same as some of my buttons…
I had this issue and I was using MooTools 1.2 (full installation).
I had forms where I was adding onSubmit events to, but was using the MooTools .addEvent method to do it.
I changed from this format:
myform.addEvent(’submit’, function(){
To this format:
myform.onSubmit = function(){
The error went away for me after that. Maybe it’s a bug in the MooTools library in my case.
Little issues always seem to be the problematic ones and they’re sooo easy to miss when trying to debug an issue.
Sometimes I forget to declare a JavaScript variable, this ‘can’ cause a lot of issues in Internet Explorer. So it’s always best to develop with IE and then test it later with FF, and Safari etc. Well that’s my 2 cents.
I am having the same problem. I am trying to help build a website on Webs.com but when I get on the website it always says done but with errors on the page. I think it is my computer because I have another friend who went to the same website without problems. Does anyone know what is going on? I am using IE7
I”m facing this error when i’m calling a cfc function thorugh ajaxproxy. not getting what can be the reason?
Please suggest somthing.
I was getting the same error. My problem was
I had form inside form. Since IE doesn’t like nested forms, It will throw an error.
I am also getting the same error when i trying to submit the form. i am trying to call thejava script select box onchange event. in that java script i tried function function doSort()
{
document.getElementById(”hdnSorting”).value = “;
document.frmparticipants.submit();
//frmparticipants.submit();
}
but no luck , can any one help me out .
hi Even i got a same problem
line 12
char 5;
Object doesn’t support this property or method
while using JavaScript Application ……
Solution :-
i just Track the path using alert();
and System.out.println();
problem got solved itself
this was driving me crazy, but makes so much sense when put in perspective of objects, thought have reconized that… thanks so much for the help, great lil’ tip!
Got the same error, it was really hard to spot the line with the error, I used try catch for every line of code on the part of the code that I suspected:
try{
some code…
}catch()e{
alert(e.message)
}
some the error I made was that I used the same identifier as an html id and a JavaScript variable.
Thank you so much! This error was driving me insane!!!
You saved me a lot of headache!
Great thanks to you!
I’ve being stuck with that problem for quite long time…
I could not even consider it was so simple
ok, I have been getting this error as well. I’m pretty computer slow so I can’t too much understand what you guys are saying. on line 93 is causing the Object doesn’t support this property or method. var check = NeoExecCheck.CheckDuplicate(). First, how do you go about changing it?
i’m having this error on the following code its in the onchange of a drop down box – $(this.form).request({ parameters: {refresh: “Y” },
onComplete: function (r) { $(”city_list”).update(r.responseText)}});
now every time i change the value of the drop down, i expect a request to my server and some content back in the div id city_list … but instead i am given this Error: Object doesn’t support this property or method…
funny enough – other projects work perfectly with the same mechanics … please help
Error: Object doesn’t support this property or method when trying to take courses from LETN for work. I was told it was a problem with Version 6 Update 10 and later. The new Java plug-in causes an incompatability when launching the DVOD content. It was suggested by the site I switch to an older version of Java which doesn’t have this incompatability problem. I would do that but I don’t have an older version of Java on my computer. I need to get started on these courses.(work related) do any help would be much appreciated. Thanks
I’m having a similar problem. I figured out how to prevent it, but I’m not sure why exactly it works.
Here’s a test case:
=========================
g = {};
function onClickEd ()
{
alert (’1′);
edURL = document.getElementById(”edURL”);
alert (’2′);
}
=========================
This gives me the “Object doesn’t support…” error when it attempts to do the assignment.
The error goes away if I do one of these things:
1. var edURL = document.getElementById(”edURL”);
2. g.edURL = document.getElementById(”edURL”);
3. edURLx = document.getElementById(”edURL”);
4. Enclose the elements in a form (which was anonymous in my test).
Am I right in assuming that in IE the input elements that aren’t in a form and have IDs become global variables (er, properties of Window)?
Interesting – I think WordPress deleted all my html tags. The script is, of course, inside (script) tags. Let’s see if I need to escape the angle brackets. Here is the HTML that comes after the script:
<body>
<input type=’text’ id=’edURL’ size=40>
<input type=’button’ value=’Test’ onclick=’onClickEd()’>
</body>
BTW, regarding a couple comments above: you don’t HAVE to use var when declaring a variable; it’s just that if you don’t, it becomes a global variable. Var makes it local to the function it’s declared in.
Personally I always declare a global object called “g” & put all my “globals” in there, just so their scope is obvious when reading the code.
I think you just saved my bacon. My site works great using FF but croaks mightly on IE 6 and 7 with an error message that is basically, “error.”
Looks like I have a conflict between a CSS ID and a javascript global variable name.
A noob question, i came across this blog when searching for the error.
Except i’m getting the same error using jsquery
Here is the code
$(document).ready(function() {
$(’input[type="image"]‘).hover(
function () { $(this).attr(”src”, $(this).attr(”src”).split(’-off’).join(’-on’)); },
function () { $(this).attr(”src”, $(this).attr(”src”).split(’-on’).join(’-off’)); }
);
});
Jane
i find the error “Object doesn’t support this property or method” when i run the code below.in Internet explorer 7.
$(”#time_go_school”).timeEntry({
spinnerImage:’images/timeEntry3.png’,
spinnerSize: [20, 25, 5],
show24Hours: true,
showSeconds: false,
separator: ‘:’,
ampmPrefix: ‘ ‘
});
$(”#time_return_home”).timeEntry({
spinnerImage:’images/timeEntry3.png’,
spinnerSize: [20, 25, 5],
show24Hours: true,
showSeconds: false,
separator: ‘:’,
ampmPrefix: ‘ ‘
});
$(”#pick_go”).timeEntry({
spinnerImage:’images/timeEntry3.png’,
spinnerSize: [20, 25, 5],
show24Hours: true,
showSeconds: false,
separator: ‘:’,
ampmPrefix: ‘ ‘
});
$(”#time_return_home”).timeEntry({
spinnerImage:’images/timeEntry3.png’,
spinnerSize: [20, 25, 5],
show24Hours: true,
showSeconds: false,
separator: ‘:’,
ampmPrefix: ‘ ‘
});
$(”#pick_go”).timeEntry({
spinnerImage:’images/timeEntry3.png’,
spinnerSize: [20, 25, 5],
show24Hours: true,
showSeconds: false,
separator: ‘:’,
ampmPrefix: ‘ ‘
});
$(”#set_go”).timeEntry({
spinnerImage:’images/timeEntry3.png’,
spinnerSize: [20, 25, 5],
show24Hours: true,
showSeconds: false,
separator: ‘:’,
ampmPrefix: ‘ ‘
});
$(”#pick_ret”).timeEntry({
spinnerImage:’images/timeEntry3.png’,
spinnerSize: [20, 25, 5],
show24Hours: true,
showSeconds: false,
separator: ‘:’,
ampmPrefix: ‘ ‘
});
$(”#set_ret”).timeEntry({
spinnerImage:’images/timeEntry3.png’,
spinnerSize: [20, 25, 5],
show24Hours: true,
showSeconds: false,
separator: ‘:’,
ampmPrefix: ‘ ‘
});
Please help me
Hello all – I am struggling with the same error. This program did work and then all the sudden it stopped working when I tried to use it on a different computer – same OS. Does anyone have any insight?
Dim fs, f, objFolder, objSubFolder, objFile, strLine, strLine2
Const ForReading = 1
‘*** Format the date
strYr = Year(date)
strMth = Month(date)
strDay = Day(date)
if len(strYr) < 4 then
strYr = “20″ & Year(date)
end if
if len(strMth) < 2 then
strMth = “0″ & Month(date)
end if
if len(strDay) < 2 then
strDay = “0″ & Day(date)
end if
dtDate = strYr & “-” & strMth & “-” & strDay
‘*** Open two files – the original file to read from and the new file to write to
‘ ERRORS ON THE BELOW STMT
Set objFSO = CreateObject(”Scripting.FileSystemObject”)
Set objFolder = objFSO.GetFolder(”C:\Documents and Settings\User\My Documents\MWM\MWM Demo Startup\orders”)
Thanks a lot…I wasted my whole day trying to solve this error..Thank you very much..
i m having the problem Object doesn’t support this property or method”.in javascript file.
please help me out
Object doesn’t support this property or method”. will u tell me the way to come out from this problem
I had this problem because when I wrote a js function, I had something like: function nameF(String param){…}. It should be function nameF(param){…}
Thanks for the article. It helped me in identifying where the issue was @ a crucial time
what i found to be happening was i wasn’t declaring local variables with “var”, bad habit…i know. However, once I did added “var” to the local variable declarations, IE ran fine.
Thanks. This article really helped me save a lot of time.
Spelling and uppercase/lowercase are also quick things to check when getting this error. “getElementByID” is wrong, “getElementById” is right.
” #30 mark on 01.13.09 at 1:04 am
For mine, the system is working for 2-3 times and then it is throwing this error of object doesn’e support…..
Means when i start the applicaiton works fine but after a certain 2-3 times clicking it throws this error.
Please help me out in this
”
I’ve been working on this same exact error off and on now for the last month (had to dedicate time to more important stuff), and I seem to have just solved it.
It was happening specifically and only to an iframe element I have pointing to an .htm page with a Flowplayer video, while a secondary fancybox element on the same page that was consequently NOT calling an iframe was consistently working just fine.
So, like everyone else here has been saying, it was a simple error and totally my own damn fault…
Here was the offending code:
$noConflict(”#video_fit”).fancybox({
‘padding’ : 0,
‘autoScale’ : false,
‘transitionIn’ : ‘none’,
‘transitionOut’ : ‘none’
});
And here is all I did to fix it:
$noConflict(”#video_fit”).fancybox({
‘padding’ : 0,
‘autoScale’ : false,
‘transitionIn’ : ‘none’,
‘transitionOut’ : ‘none’,
‘type’ : ‘iframe’
});
That’s right… I was missing the line:
‘type’ : ‘iframe’
Hope this helps for someone else in the future pulling their hair out about yet another IE inconsistency, (though in IE’s defense, it’s a totally valid error).
Leave a Comment