Need some help
I have to events on my index page, but i cant get them both two work at the same time. I know that i cant use window.onload on both of them, that will only make one of the event too work. But i don't know how too modify the script to make the both work. I dont want the onclick in the html file, it has to be in the js file.
popup.js
the url.jsCode:window.onload = initImages; function initImages() { var allImages= document.getElementsByName("big"); for (var i=0; i<allImages.length; i++) { allImages[i].onclick = newWindow; } } function newWindow() { var imgName = "images/" + this.id + ".jpg"; var imgWindow = window.open(imgName, "imgWin", "width=430,height=340,scrollbars=no"); }
the htmlCode:window.onload = initExtlink; function initExtlink() { var allExternallinks= document.getElementsByName("external"); for (var i=0; i<allExternallinks.length; i++) { allExternallinks[i].onclick = newConfirm; } } function newConfirm() { if(confirm('Du är på väg att lämna sidan. Klicka på OK för att fortsätta')) { return true; } return false; }
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3c.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="url.js"></script> <script type="text/javascript" src="popup.js"></script> <title>Index</title> </head> <body> <a name="external" href="http://www.kissonline.com">Kissonline</a> <img name="big" class="bottom" src="images/diego_thumb.jpg" alt="Diego - Border Terrrier" id="diego" /> </body> </html>


Reply With Quote
Bookmarks