Hello programmer and coders!
I´m just starting to learn about JavaScript. And Im trying to make a function were I can put all links that schould have an alert box coming up when they click the link. I have putted this function togheter (that dont work..yet!):
- Code:
-
function init(){ // load the page
function go_to() {
var link = new Array();
//links that schould have this function:
link[0] = "http://www.capoeiras.se/";
link[1] = "http://www.koanuka.com";
link[2] = "http://www.matochhushallning.blogspot.com";
//ok or cancel:
new_url = link[num];
if (!confirm ("You are leaving this site, do you want that?")){
window.location = new_url;
} else {
return false
}
}
//här avslutas init
}
}
window.onload = init;
Do I need to have onclick here? Im thankful for any help I can get!!!