Controlling inner HTML / HTML widget


#1

I have an HTML widget containing an iframe for a video. If, while the video is playing, the user clicks on another button, I would like the video to stop playing. I have used this:

var emptyInnerHTML = ''; 

hypeDocument.getElementById(“Video”).innerHTML = emptyInnerHTML

This effectively empties the widget and stops it playing. However, how can I reload the innerHTML with the iframe once again?

Thanks!


#2

You would use the iframe src code and just load it right back in. Note that I use " inside of the JavaScript string, but ' to encapsulate it.

var newinnerContent = '<iframe src ="https://www.youtube.com/embed/#####" width="400px" height="400px" scrolling="no" style="border:none;"></iframe>';

document.getElementById("Video").innerHTML = newinnerContent

#3

works perfectly. Thanks!


(Daniel Martínez) #4

Thank you very much for your contribution, it was very helpful. regards