Button und Link per Button ändern | So sieht´s aus |
Klick HIER um Link zu ändern |
Quellcode |
<html>
<head> <style type="text/css"> Hier nichts</style> </head> <body> <center> <input type="button" id="button" onclick="window.open(this.name)"> <br /><br /> <a id="aendern" onclick="fZufallslink()">Klick HIER um Link zu ändern</a> <script type='text/javascript'> var link = new Array(); link[0] = "http://htmlknowhow.de"; //Erster Link link[1] = "https://meinsolargarten.de"; //usw. link[2] = "http://histohp.lmfd.de"; var linkbeschreibung = new Array(); linkbeschreibung[0] = "htmlknowhow"; //Beschreibung für den ersten Link linkbeschreibung[1] = "meinsolargarten"; //usw. linkbeschreibung[2] = "histohp"; var anzahl_links = link.length; var aktuellerlink = 0; //NICHT ÄNDERN function fZufallslink(){ aktuellerlink = Math.floor(Math.random()*anzahl_links); while(aktuellerlink > anzahl_links){ aktuellerlink = Math.floor(Math.random()*anzahl_links); } document.getElementById('button').value = linkbeschreibung[aktuellerlink]; document.getElementById('button').name = link[aktuellerlink];} </script> <script type="text/javascript">fZufallslink();</script> </center> </body> </html> |