/    Sign up×
Community /Pin to ProfileBookmark

Object doesn’t support…. Error

I’m getting this error and I’m not sure what is actually causing it:
—————————————————————

Line: 131
Char: 2
Error: Object doesn’t support this property or method

Code: 0
—————————————————————

I only get the error in IE, all other browsers run the script fine.

It relates to this function:

[CODE]
function addConference(divName)
{
var divnum = document.getElementById(divName);
var confCounter = divnum.getElementsByClassName(‘confSub’).length;
var newdiv = document.createElement(‘div’);
if (confCounter % 2)
{
newdiv.innerHTML += “<div class=’gray confSub’> <input type=’hidden’ name=’newConf[” + confCounter + “]’ value=’new’ /> <label>Conference Attended:</label><input size=’85’ name=’conference[” + confCounter + “]’ type=’text’ /> <label>Date:</label> <input size=’20’ name=’confDate[” + confCounter + “]’ type=’text’ /> <span class=’example left’> ( YYYY-MM-DD )</span> <label class=’fullLabel clearfix’>Description and Benefit to the University:</label> <textarea name=’confDesc[” + confCounter + “]’ cols=’90’ rows=’5′></textarea> <input class=’checkbox clearfix’ name=’confPres[” + confCounter + “]’ value=’yes’ type=’checkbox’ /> <label class=’midLabel’>Conference Presentation?</label> <label class=’clearfix’>Title of Presentation:</label> <input class=’pushLeft’ size=’85’ name=’confPresTitle[” + confCounter + “]’ type=’text’ /> </div>”;
}
else
{
newdiv.innerHTML += “<div class=’white confSub’> <input type=’hidden’ name=’newConf[” + confCounter + “]’ value=’new’ /> <label>Conference Attended:</label><input size=’85’ name=’conference[” + confCounter + “]’ type=’text’ /> <label>Date:</label> <input size=’20’ name=’confDate[” + confCounter + “]’ type=’text’ /> <span class=’example left’> ( YYYY-MM-DD )</span> <label class=’fullLabel clearfix’>Description and Benefit to the University:</label> <textarea name=’confDesc[” + confCounter + “]’ cols=’90’ rows=’5′></textarea> <input class=’checkbox clearfix’ name=’confPres[” + confCounter + “]’ value=’yes’ type=’checkbox’ /> <label class=’midLabel’>Conference Presentation?</label> <label class=’clearfix’>Title of Presentation:</label> <input class=’pushLeft’ size=’85’ name=’confPresTitle[” + confCounter + “]’ type=’text’ /> </div>”;
}
document.getElementById(divName).appendChild(newdiv);
}
[/CODE]

and is this line in particular:

[CODE]
var confCounter = divnum.getElementsByClassName(‘confSub’).length;
[/CODE]

Any ideas?

Thanks in advance,
Shannon

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Sterling_IsfineSep 27.2010 — .getElementsByClassName isn't supported by all IE versions, so you'll have to implement it in its absence.
Copy linkTweet thisAlerts:
@KorSep 27.2010 — I use this crossbrowser approach:
<i>
</i>onload=function(){
if (!document.getElementsByClassName) {
document.getElementsByClassName = function (cn) {
var rx = new RegExp("(?:^|\s)" + cn+ "(?:$|\s)");
var allT = document.getElementsByTagName("*"), allCN = [], ac="", i = 0, a;
while (a = allT[i=i+1]) {
ac=a.className;
if ( ac &amp;&amp; ac.indexOf(cn) !==-1) {
if(ac===cn){ allCN[allCN.length] = a; continue; }
rx.test(ac) ? (allCN[allCN.length] = a) : 0;
}
}
return allCN;
}
}
}
×

Success!

Help @meisenheimer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...