How to Disable Clicking in an Iframe

Techwalla may earn compensation through affiliate links in this story.
Image Credit: avemario/iStock/Getty Images

An iframe is an HTML element that displays content from an external page. Sometimes, web developers may wish to prevent the user from clicking on an iframe or the contents of an iframe. Typically, clicking on elements is disabled by using Javascript to set the element's "onclick" event to "return false." Unfortunately, there is no onclick event for iframe elements. However, clicking can still be disabled by placing an invisible blocking overlay over the iframe.

Advertisement

Step 1

Type the code

above your

Video of the Day

Step 2

Type the code

below the line you typed in Step 1. Replace [width] and [height] with the width and height of your iframe.

Advertisement

Step 3

Type a closing div tag

below your iframe tag.

Advertisement

Advertisement