0

I want to embed a web page in to my website and be able to listen for clicks on the element.

<object id="test" class="col-xs-12 col-md-10" type="text/html" data="http://validator.w3.org/" style="margin-top: -5px;" height="580px">Your browser sucks!</object>        
  • I have tried adding onclick to it. I have tried using .click function event in script.
  • I have tried wrapping the <object> in a <div> but any clicks in the <object> are not seen.
  • I have even used body and window click functions - it's as if <object> element no longer exists on my website, only clicks outside the <object> work.
  • The same behaviour also happens on iframes.
Turnip
  • 35,836
  • 15
  • 89
  • 111
Danny Keeley
  • 23
  • 1
  • 1
  • 6

3 Answers3

1

Try adding pointer-events: none; to your object element.

Roberto Zvjerković
  • 9,657
  • 4
  • 26
  • 47
0

What for me worked was adding pointers-events: none; to the style of the object.

Also tried adding a parent <div> container and playing around with z-index. Both didn't work for me.

Stagory
  • 24
  • 3
0

I used this structure to solve the click problem

<div class="icon">
  <object type="image/svg+xml" data="xxx"></object>
  <div class="click-layer" @click="alert('hello')"></div>
</div>

<style>
.icon {
  position: relative;
}
.icon .click-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: transparent;
}
</style>
jethroHEX
  • 1
  • 1