I have a svery simple requirement. I have a <div>
tag within which I am displaying some text content.
I want to display the same text content in an <iframe>
. What I am trying to achieve I have written below. Can anyone please help?
<b>
<div>This is a content which I want to display in iframe</div>
<iframe id="iframe" src=""></iframe></b>
If it is a static HTML site, create a new page with the content which you want to show and set the src
of the <iframe>
.
If it is a dynamic page app (server side), create a new page
or handler
or controller
(whatever applies) and set the src
of the <iframe>
.
These are the best and simplest ways to achieve what you want to accomplish.
Found a solution which worked for me. Use srcdoc instead of src. It will display your static content inside iframe.
Below is the code:
<iframe srcdoc="<div>This is a content which I want to display in iframe</div>"></iframe>
Hope this is what you are looking for. Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With