test/script/Accueil.js

40 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

//while (confirm("pute ?")) {
/*alert('Hello world!');
if (confirm("sûre ?"))
parseInt(prompt("Entrez l'étage où l'ascenseur doit se rendre (de -2 à 30) :"));
else {
alert("Tamr");
}
}*/
2018-05-15 20:54:04 +02:00
var image = document.getElementsById('link_line');
console.log(image);
var child = image.lastChild;
while (child) {
if (child.nodeType === Node.ELEMENT_NODE) { // C'est un élément HTML
//alert(child.firstChild.data);
} else { // C'est certainement un nœud textuel
//alert(child.data)
}
child = child.previousSibling; // À chaque tour de boucle, on prend l'enfant précédent
}
//var image = document.getElementsById('image');
var divs = document.getElementsByTagName('div');
for (var i = 0; i < 3; i++) {
2018-05-15 20:54:04 +02:00
var newElement = divs[i].appendChild(document.createElement('a'));
url = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2);
console.log(url);
2018-05-15 20:54:04 +02:00
for (var j = 0; j < url.length; j++) {
url[j] = url[j] % 26 + 'a'
}
newElement.title = 'tanche'
newElement.href = 'http://' + url + '.com'
newElement.appendChild(document.createTextNode("pte"));
}
console.log("fin");