forum

Home / DeveloperSection / Forums / document.body.appendchild has a null value.

document.body.appendchild has a null value.

Anonymous User292723-Mar-2015

I am loading a .js file I wrote. Within that .js file I am creating a Iframe like this.

var frmSource = "http://MYLINK.com/mypage.html?" + encodeURI(URLBuilder);
    ifrm = document.createElement("IFRAME");
    ifrm.setAttribute("src", frmSource); a
    ifrm.style.width = 0 + "px";
    ifrm.style.height = 0 + "px";
    ifrm.setAttribute("frameBorder", "0");
    document.body.appendChild(ifrm);

URLBuilder contains the GET variables to the next page

The issue occurs at document.body.appendChild(ifrm);

and my error is javascript typeerror: null is not an object (evaluating 'document.body.appendchild')

I suspect the issue is it is trying to append the iframe to the body but the body has not properly loaded. I am currently only getting this issue in safari.


Updated on 23-Mar-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By