Moved the javascript to a separate file.

Signed-off-by: retep998 <retep998@verizon.net>
This commit is contained in:
retep998 2013-03-07 13:19:46 -05:00
parent bf8cebf6ce
commit 3e62e81982
2 changed files with 19 additions and 13 deletions

View File

@ -2,25 +2,14 @@
<html>
<head>
<title>What is this I don't even.</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<h1 id="poke">Sup?</h1>
<a href="http://www.google.com/">This is a link to google</a>
<a href="javascript:analyze();">Click me to analyze the page.</a>
<form class="blah">
<input id="foo" name="lel" type="text" />
<input id="bar" type="submit" />
</form>
</body>
<script type="text/javascript">
var all = document.getElementsByTagName("*");
for (var i = 0; i < all.length; ++i) {
var info = new Array();
info[0] = all[i].tagName;
info[1] = all[i].getAttribute("id");
info[2] = all[i].getAttribute("name");
info[3] = all[i].getAttribute("class");
info[4] = all[i].getAttribute("type");
alert(JSON.stringify(info));
}
</script>
</html>

17
test.js Normal file
View File

@ -0,0 +1,17 @@
function analyze() {
var all = document.getElementsByTagName("*");
for (var i = 0; i < all.length; ++i) {
var info = new Array();
var validtags = ["A", "BUTTON", "FORM", "IMG", "INPUT", "LINK", "OPTION", "SELECT", "TABLE", "TEXTAREA"];
if (validtags.indexOf(all[i].tagName) < 0) continue;
info[0] = all[i].tagName;
info[1] = all[i].getAttribute("id");
info[2] = all[i].getAttribute("name");
info[3] = all[i].getAttribute("class");
info[4] = all[i].getAttribute("type");
dostuff(info);
}
}
function dostuff(info) {
alert(JSON.stringify(info));
}