Code don't work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Code don't work

i try to create a javascript code to create links but i can't understand why "show code" button don't work. https://code.sololearn.com/WK8YWg9ZGSO6/?ref=app https://code.sololearn.com/WK8YWg9ZGSO6/?ref=app

13th Apr 2017, 7:58 PM
Stefano Trinca
Stefano Trinca - avatar
3 Answers
+ 20
var link= prompt("insert the url of your site") if (link) var text= prompt("insert the text to show") window.onload = function() { var el = document.getElementsByTagName('a'); el[0].href= link; var x = document.getElementById('LinkText'); x.text = text ; var w = document.getElementById('button'); w.onclick =function() { var z = document.getElementById('codeToShow'); z.innerHTML = "<a href=\""+link+"\">"+text+"</a>"; } }; copy paste this..... is this what you want??
13th Apr 2017, 8:15 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 2
what do you want it to do?
13th Apr 2017, 7:59 PM
Mario L.
Mario L. - avatar
+ 2
If you are trying to click the link, and go to the website the person put in the prompt, it's really not going to work. The code playground doesn't work anchor links like that and will just show a blank page on the area of the code playground
13th Apr 2017, 8:07 PM
Welliton Malta
Welliton Malta - avatar