Hiya
I have created a small html with some javascript that runs through and picks up <a hrefs> and opens the links in new tabs (to check raw html for dead links)
It also pastes the links on the same page, thing is, in my loop as you'll see below it pastes the link then I try to <br /> to display the next underneath like so (on the same page):
Link
Link
Basically it works perfect for link 1 but it doesnt loop back around and grab the 2nd link.
Ideally I would like numbered links with a total at the bottom, I've been sitting trying to do it for about 3 hours now
Heres my code, will explain much faster if you run it:
Code:
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript">
<!--
function open_links()
{
document.getElementById("htmlDiv").innerHTML = document.getElementById("htmlArea").value;
a = document.getElementById("htmlDiv").getElementsByTagName("a");
for(i=0; i < a.length; i++)
{
window.open(a[i].href);
var divReport = document.getElementById("report");
report.innerHTML = (a[i].href);
document.report.write(item );
document.write("<br\/>");
}
}
-->
</script>
</HEAD>
<BODY>
<div>
<textarea id="htmlArea" cols=50 rows=20></textarea>
<button onclick="open_links();">Check Links</button>
<div style="font-family: Lucida Console; color: rgb(255, 255, 255); font-size: 12px; background: none repeat scroll 0% 0% black; width: 523px;" id="report">
</div>
</div>
<div id="htmlDiv" style="display: none;"></div>
</BODY>
</HTML>
If anyone has an idea why it wont run I'd be greatful, because what I can do is make it work fine but it makes a new page, I want it on the same page below the text area
Thanks in advance for any help!
Liam