Go Back   CodingForums.com > :: Client side development > JavaScript programming > Post a JavaScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-13-2004, 12:14 AM   PM User | #1
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
Link List and Jumpmark Checker

Hello,

This script seems to work pretty well, it is IE only. View Source on a web page and save it as a .txt to your desktop. This script will take the file and list all links on the page. It will also check to ensure that all jumpmarks are properly defined.

Code:
<html>
<head>
<script language="javascript">
function go(path)
{
var sfo=new ActiveXObject('scripting.FileSystemObject');
var fileLoc=sfo.OpenTextFile(path);
str=fileLoc.readall();
str=str.toLowerCase();
var cut=str.split('<a href=')
var str2=""

	for(i=0;i<cut.length;i++)
	{
		var stop=cut[i].indexOf('</a>');
		var url=cut[i].substring('0',stop);
		var url='<a href='+url+'</a><input type="checkbox">'
		str2+=url+'<br>';
	}
	
info.innerHTML=str2;
}

function getBookMarks()
{
	list1=new Array();
	var cut=str.split('<a name=');
	
	for(i=0;i<cut.length;i++)
	{
		var stop=cut[i].indexOf('>');
		var aname=cut[i].substring('0',stop);
		list1[i]=aname;
	}
	getHref();
}

function getHref()
{
	var strg="";
	var cut=str.split('<a href="#');
	yep=0;
	for(i=1;i<cut.length;i++)
	{
		var stop=cut[i].indexOf('">');
		
		var aname=cut[i].substring('0',stop);
		var check=0;
		for(j=0;j<list1.length;j++)
		{
			if(aname==list1[j])
			{
				check=1;
			}
		}
		if(check==0)
		{
			info2.innerHTML+='The bookmark '+aname+' seems to be missing.<br>';
			yep=1;
		}
		
	}
	if(yep==0)
	{
info2.innerHTML="Every hyperlink points to a defined jumpmark,"+
" this does not mean they necessarily point to the right jumpmark."
	}
}
</script>
</head>
<body onload="go()">
<table border="0" style="text-align:center;">
<tr>
	<th>File Name</th>
</tr>
<td>
<input type="text" id="filen"></td><td>
<input type="button" value="Get Links" onclick="go(document.getElementById('filen').value);">
<input type="button" value="Check Jumpmarks" onclick="getBookMarks()"></td></tr></table>
<div id="info2">
</div>
<div id="info">
</div>
</body>
</html>
Basscyst
__________________
Helping to build a bigger box. - Adam Matthews
Basscyst is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:31 AM.


Advertisement
Log in to turn off these ads.