As valid to add the script in head?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
9 views
Hello

There is a code

(function(){ 'use strict'; loadContentToHead function(){ var head = document.querySelector('head'); var containerScriptToHead = document.createElement('div'); containerScriptToHead.id = 'containerScriptToHead'; head.appendChild(containerScriptToHead); var xhr = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); xhr.open('get', 'file-scripts.html', true); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { head.innerHTML = xhr.responseText; } else{ console.log('Error'); } } xhr.send(); } loadContentToHead(); })();


Now everything works, but creates a div (the validator complains)
In htmlwhich is loaded, is the script, so to use the script can't
by | 9 views

1 Answer

0 like 0 dislike
Of course div is created you can add it there, in this place:
var containerScriptToHead = document.createElement('div'); containerScriptToHead.id = 'containerScriptToHead'; head.appendChild(containerScriptToHead);

remove these three lines from the script and everything will be fine
by
110,608 questions
257,186 answers
0 comments
35,456 users