asynchorous calling of an external script in document.write

by Ramshan 2014-10-13 18:39:20

During the async call of an external script, check whether you have called the js file which doesn't contain document.write().

As you are trying to load the external file at last without affecting the page, it won't load the document.write content in async call.

When you call js file in async mode, it will throw the error as,
A call to document.write() from an asynchronously-loaded external script was ignored.

Hence change the document.write content to alternate methods like, creating the element using document.createElement()...and then append it to the page like, document.body.appendChild(element);


For eg,
var iframeEle = document.createElement("iframe");
iframeEle.setAttribute("src", path);
iframeEle.width = width+"px";
iframeEle.height = height+"px";
iframeEle.frameBorder = 0;
document.body.appendChild(iframeEle);
1543
like
0
dislike
0
mail
flag

You must LOGIN to add comments