I probably did this the wrong way, I learned Jquery first and easy stuff. Taking a course in javascript learning DOM0 & DOM1 and just cannot get this to work.
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript">
function addBorder(){
for var i=0; i<document.getElementsByTagName('img').length; i++) {
document.getElementsByTagName('img')[i].style.border="3px solid red");
}
}
</script>
<script type="text/javascript">
window.onload=addBorder;
</script>
</head>
<body>
<img src="image1.jpg" />
<img src="image2.jpg" />
</body>
</html>
Quickly typed, ignore typos if there are any. Results in no errors and no activity.
Tried it all different ways, DOM0 document.images..., window.onload=function(){....
Always nothing. Get the basic idea that images are loading after script, if placed in body it works fine. But why would it not work within window.onload=??