I have an iframe with an inherited pointer-events: none;
but when I have inserted a <div>
inside the iframe with a pointer-events: auto;
the div won't react to clicks or any mouse hover events.
The reason for this is that the iframe
is inside a <div style="position:fixed;">
so it is kind of like a little menu. but I would like the user to click through the iframe
, but not through the links and divs in the iframe.
And yes, it absolutely needs to remain an iframe.
How could I bypass this? Can I even bypass this?
Here's a simple example: jsfiddle.net/MarcGuiselin/yLo119sw/2
Don't give the whole iframe
pointer-events: none
. Just inside theiframe
put a CSS rulebody * { pointer-events: none;}
This way the iframe does not block events, however elements inside the iframe are not clickable.
Have you tried this?
I know you already got your answer, but I thought this might work, too.
You're working with
position:absolute
, according to the example you've uploaded on jsfiddle... Adding az-index
to the "you can't click me because i'm behind the iframe" button allows me to click it.Z-Index
EDIT: If you want to do a
pointer-events: none;
everywhere except in onediv
, you can add thepointer-events
in eachelement
instead of theiframe
. According to your example in the fiddle, if you want to save the Nicholas Cage but block the other events, you can do something like this:If you can use jQuery you can do it faster just using
$("iframe *").css("pointer-events","none");