Can't remove iframe by class rather than ID

(BIlly) #1

I’m trying to unload an iframe so it stops video playing.

This works but I want to use classes instead as I don’t want to create unique id’s for every video!

hypeDocument.getElementById("vimeovideo1").innerHTML = ' '

I tried these but none work:

hypeDocument.getElementsByClassName("vimeovideo").innerHTML = ' '


hypeDocument.getElementById(hypeDocument.documentId()).getElementsByClassName("vimeovideo").innerHTML = ' '

Help apprecieted.

(Andrew) #2

I would use jQuery if you want to grad elements by class.

(BIlly) #3

Ok so how would I do that?

I need it to be part of hype and not called up externally in html page though.

Stopping Video When Changing Scenes
(Andrew) #4 (72.4 KB)

Drop this into the resources file, and make sure its ticked at the bottom to include in the header, and then use something like:


How to stop a youtube video, switching to another scene?
(BIlly) #5

Ta. That did the job. Shame have to load the resource but at least it works for classes now. Cheers.

(René) #6

This will give you an array of all elements with this classname. You’ll have to loop this thru like:

var i
var vElements = document.getElementsByClassName("vimeovideo")
for (i = 0; i < vElements.length; i++) {vElements[i]. innerHTML = '';}

(BIlly) #7

Nice. That works too!

(Pablo) #8

can someone explain where to add this code exactly? Many thanks!


You would put this in a function and call it whenever you want. Say on mouse click of an element.

But, I wouldn’t just empty the contents. I would use the video.pause method but hey that’s just me.

(chans) #10

How to display video again? help me please.