I'm playing around with web development and looking to test some dynamically generated content, specifically just listing in a Chrome Extension popup all of the links on a site page. I referenced a great resource here but I was testing with an output
tag versus a ul
and the creation of li
for that list to show on the page.
popup.html
<div>
<h3>Page output</h3>
<output id="outputkey3">pages go here</output>
</div>
popup.js
function (tabs) {
var tab = tabs[0];
var url = tab.url;
if (url != null) {
var host = new URL(url).hostname;
...
var outputKey3 = document.getElementById("outputKey3")
if (outputKey3 != null) {
for(var i = document.links.length; i --> 0;) {
if(document.links[i].hostname === host) {
//urls.push(document.links[i].href);
outputKey3.appendChild(document.links[i]);
}
}
}
Even for a single link this does not seem to be working. Not sure if this is meant to be done with a list versus another element that does not format the data with a preceding number or •. What I'd really like to do is just show a list that looks like a new line of data for each index value, perhaps as a bunch of p
's.