i need to repeat this several times... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

i need to repeat this several times...

hi friends... some time ago, I was looking for a function that delayed the loading of a page from a hyperlink. I finally do it, but now I face another challenge ...how to apply the same function on several links??? is it possible? here is the code: https://code.sololearn.com/WucwujIkqsB0/#js

2nd Dec 2018, 9:19 PM
Lorenzo Sandoval
Lorenzo Sandoval - avatar
2 Answers
+ 1
Hey, just give the function assigned to the onclick event a name like this: function delayClick() { var www = this.href; var f = function(){ window.location.href=www }; setTimeout(f,250); return false; } And every time you want to use it on a link, give the link an id, say link1 for example, then add this to this script: document.getElementById('link1').onclick = delayClick();
2nd Dec 2018, 11:24 PM
Hamza Alalach
Hamza Alalach - avatar
0
thank you very much friend, your help solved my problem ....
21st Dec 2018, 3:37 AM
Lorenzo Sandoval
Lorenzo Sandoval - avatar