1
I have a file HTML
which I want to count all tags a
existing. I have already been able to develop the script that does this count using Local Storage.
My goal is:
When loading the page
index.html
, the script go in the other filehtml
that I want and count the tags.Let this count be displayed in a
td
in theindex.html
Here follows the counting script and Local Storage:
var linkCount = document.body.querySelectorAll('a').length,
hrefs = document.body.querySelectorAll('a[href]');
localStorage.setItem("links", linkCount);
document.getElementById("total").innerHTML = localStorage.getItem("links");
The above script is only running locally, i.e., where his is done.
I imagine there is a way to call the file I want in the execution of this script, but I can’t find.
I hope I have been as clear as possible and I can complement if I get confused. Thank you already!