Unexpected hidden div appears in html file

I tried to find this, but did not even find anyone with the same problem.

For my purpose, I had to write javascript code that would read all the text from an external page (from the same directory), but this is not a problem. The problem arose when I created a test html file with some random text.

HTML code

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>test</title> </head> <body> <p> Just a random text.</p> <h1> More of a random text</h1> <p> And again, just testing the program.</p> </body> </html> 

And this code is taken from the debugger:

Image of html file as from inspector

The problem is that my javascript code reads text from this div element and adds an array of words that I have.

Does anyone know why this div is created and how to get rid of it?

PS I tried to create other html files, but a div also appears there.

Thanks in advance!

EDIT:

What is my JS code:

 var externalPage; var words = []; var j = 0; function indexOf(array, item) { for (var i = 0; i < array.length; i++) { if (array[i][0].toString() === item.toString()) return i; } return -1; } function clearNode(node) { while (node.firstChild) { node.removeChild(node.firstChild); } } function sortNumerically(words) { return words.sort(function(a,b){ return b[1] - a[1]; }); } function sortAlphabetically(words) { return words.sort(); } function openFile(url) { externalPage = window.open(); externalPage.location = url; } function extractWords(node) { if (node.nodeType==Node.ELEMENT_NODE) { for (var m = node.firstChild; m!=null; m = m.nextSibling) extractWords(m); } else { var value = node.nodeValue.trim(); value = value.split(/\s/); for(var i = 0; i < value.length; i++) { if(indexOf(words, value[i]) != -1) { words[indexOf(words, value[i])][1] = words[indexOf(words, value[i])][1] + 1; } else if(value[i] != '') { words.push([]); words[j][0] = value[i]; words[j][1] = 1; j++; } } } } function populateTable(arr) { var tbody = document.createElement('tbody'); clearNode(tbody); for(var i = 0; i< words.length; i++) { var tr = document.createElement('tr'); var tdW = document.createElement('td'); var tdF = document.createElement('td'); tdW.appendChild(document.createTextNode(arr[i][0])); tdF.appendChild(document.createTextNode(arr[i][1])); tr.appendChild(tdW); tr.appendChild(tdF); tbody.appendChild(tr); } document.getElementById('tableCounter').appendChild(tbody); } function generateArray(node) { words = []; j = 0; extractWords(node, words); alert(sortNumerically(words)); populateTable(words); } 
+5
source share
2 answers

This hidden box is a virus effect. The dataloading.net page dataloading.net known as the viral page. You can search for it using your favorite search module (google, bing, ...).

+3
source

How the bound code binds the DIV specifically from JS or any JS plugin that simply attaches to the body with the generated code.

0
source

Source: https://habr.com/ru/post/1264236/


All Articles