Shifra
Shifra

Reputation: 41

Scroll wheel doesn't work when cursor is on iframe

I have an iframe with a youtube video inside an html page. When I try scrolling, I cannot scroll while my mouse is over the iframe. I found this question below but param doesn't help me as this is an object and mine is an iframe.

Avoid scroll-wheel hijack by embedded youtube / flash video

I saw the solution to put an invisible div on top, but that is a problem because the user won't be able to click to pause/play the video.

Does anyone have another solution?

Thanks.

Upvotes: 2

Views: 1907

Answers (2)

Marc Hägele
Marc Hägele

Reputation: 342

You can style the iframe with the following:

style="pointer-events:none;"

Upvotes: 1

Bitz
Bitz

Reputation: 1148

You can try delegating the video play/pause functions to a button somewhere else:

var myPlayer = document.getElementById('playerid');
myPlayer.stopVideo();

Source: How can I stop a video with Javascript in Youtube?

Upvotes: 0

Related Questions