0

in this stackoverflow answer I've found how to make text unselectable, which works as expected when used inside a div and stuff. However i can not get it to work inside an iframe.

here is a jsFiddle showing my problem, the text inside the div with the unselectable class is indeed unselectable as expected, but the lorem ipsum on the website is still selectable, despite having the same unselectable class

Is this because elements inside iframe do not inherit the classes like <p> does inside <div>?

If that is the case is there a way to make any text inside the iframe unselectable (html/css/javascript)? Or can this only be done from the source code of the page displayed inside the iframe?

setting pointer-events: none is not an option either since buttons and stuff should still be interactable

Thank you for your time.

-Remy

Edit: Thanks for pointing me to this topic, this does indeed also work for disabling selecting.

Remy
  • 4,843
  • 5
  • 30
  • 60

1 Answers1

0

It's because of cross-origin policies. A workaround for this ( not beautiful ) is to iframe the iframe ( from the same origin ) and lock user-selection on that.

Joelgullander
  • 1,624
  • 2
  • 20
  • 46