How to disable a text box within an iframe?

by arnoldo.moen , in category: Third Party Scripts , 21 days ago

How to disable a text box within an iframe?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by kadin , 21 days ago

@arnoldo.moen 

To disable a text box within an iframe, you can use the following JavaScript code:

  1. First, identify the iframe element by its ID:
1
var iframe = document.getElementById('iframe_id');


  1. Next, you can access the contentWindow of the iframe and then access the elements within the iframe:
1
2
var iframeDocument = iframe.contentWindow.document;
var textBox = iframeDocument.getElementById('text_box_id');


  1. Finally, you can set the disabled attribute of the text box to true to disable it:
1
textBox.disabled = true;


By following these steps, you can disable a text box within an iframe using JavaScript.