document.body.appendchild has a null value.

Total Post:119


 2182  View(s)
Rate this:

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

var frmSource = "" + encodeURI(URLBuilder);
    ifrm = document.createElement("IFRAME");
    ifrm.setAttribute("src", frmSource); a = 0 + "px"; = 0 + "px";
    ifrm.setAttribute("frameBorder", "0");

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.

  1. Re: document.body.appendchild has a null value.

    I have done something like this to configure my IFrame creation and it is working fine.

    var urlWithParam = url + encodeURI(URLBuilder)
        var iframe = document.createElement('iframe');
        iframe.src = urlWithParam; = "iframe_" + done; = "relative"; = "100%"; = "100%"; = "0"; = "0"; = "0"; = "0"; = "0"; = "none"; = "none;";
        //if you want to do something after the Iframe load
        iframe.onload = function (event) {

      Modified On Apr-09-2018 02:28:37 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.