Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying static text content with iframe

Tags:

html

iframe

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>
like image 557
shettarvinay Avatar asked Jun 30 '13 09:06

shettarvinay


2 Answers

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.

like image 140
Vivek Jain Avatar answered Sep 30 '22 17:09

Vivek Jain


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.

like image 40
noobmaster Avatar answered Sep 30 '22 18:09

noobmaster