Carlos Longo 0 Posted June 3, 2017 Report Share Posted June 3, 2017 Para o seguinte codigo abaixo, quando digito vid, aparece somente o video, e quando digito foto, aparece a foto e o video. Como posso fazer para ter somente um video ou somente uma imagem? <html> <body> <h2>My First JavaScript</h2> <div id="video" class="UJAwNkhbYWM"><iframe id="caixa" allowfullscreen="" frameborder="0" height="200" width="250"></iframe> </div> <div id="div"><img id="img"></div> <br> Enter Text To Play: <input id="text" value=""> <br> <button class="btn btn-success" onclick="talk()">Atenas Falar!</button> <button type="button" onclick="document.getElementById('demo').innerHTML = Date()"> Click me to display Date and Time.</button> <p id="demo"></p> <script> var nota = document.getElementById("text").value; function limparimg() { document.getElementById("div").innerHTML=""; } function limparvid() { document.getElementById("video").innerHTML=""; } function videoof(){ var video = document.getElementById("video"); var video = video.className; var iFrame = document.getElementById("caixa"); iFrame.src = "https://www.youtube.com/embed/" + video; } function mostracav(){ var foto=new Array(10); foto[0]="<img src=http://www.ficasimples.com.br/eliza/cavit.jpg>"; foto[1]="<img src=http://www.ficasimples.com.br/eliza/cavit1.jpg"; foto[2]="<img src=http://www.ficasimples.com.br/eliza/cavit2.jpg>"; foto[3]="<img src=http://www.ficasimples.com.br/eliza/cavit3.jpg>"; foto[4]="<img src=http://www.ficasimples.com.br/eliza/cavit4.jpg>"; foto[5]="<img src=http://www.ficasimples.com.br/eliza/cavit5.jpg>"; foto[6]="<img src=http://www.ficasimples.com.br/eliza/cavit6.jpg>"; foto[7]="<img src=http://www.ficasimples.com.br/eliza/cavit7.jpg>"; foto[8]="<img src=http://www.ficasimples.com.br/eliza/cavit8.jpg>"; foto[9]="<img src=http://www.ficasimples.com.br/eliza/cavit9.jpg>"; foto[10]="<img src=http://www.ficasimples.com.br/eliza/cavit10.jpg>"; num=0 sorteia=Math.random(num)*6 ok=Math.round(sorteia) document.getElementById("div").innerHTML = foto[ok]; } function talk(){ var nota = document.getElementById("text").value; var vid ="vid"; if (nota == "vid") { limparimg(); videoof();} var qya ="foto"; if (nota == "foto" ) { mostracav();} } </script> </body> </html> Carlos Link to post Share on other sites
JakeBass 12 Posted June 6, 2017 Report Share Posted June 6, 2017 faltava chamar a função limparvid() e a iframe tem que ser carregada de novo. https://pastebin.com/u3NNVQMh Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now