Why do they prefer using iframe and turn on design mode by .contentWindow.document.designMode = "on" instead of directly using textarea?
Why do they prefer using iframe and turn on design mode by .contentWindow.document.designMode =
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The reason is that you won’t be able to live preview the styles applied using your editor in a textarea. Whenever you apply styles like pressing
Ctrl + Bthe section inside the iframe can render the characters in bold format whereas in a textarea it won’t be possible. Textarea is for entering non formatted values whereas a design mode turned on iframe is for entering formatted text.You can use any other element like div and can turn that into an editor. But using iframe you can have a separate document and can manipulate that without considering the parent page in which the iframe is set.