Waqas Adil
Waqas Adil

Reputation: 320

How to add iframe element tag in dialog popup using html

I want to add an iframe inside a pop up dialog. How can I add it inside this dialog popup using JavaScript.

Here is the dialog pop inside which I want to use an iframe.

Here is the Iframe tag that I want to show inside the popup. You can add any website in iframe. Thanks in advance for your help.

   <iframe src="http://www.w3schools.com"></iframe>

Upvotes: 1

Views: 952

Answers (1)

Anurag Sinha
Anurag Sinha

Reputation: 1032

You cannot display google.com inside an iFrame. Reason being that Google sends an "X-Frame-Options: SAMEORIGIN" response header. This option prevents the browser from displaying iFrames that are not hosted on the same domain as the parent page. This is a security feature to prevent click-jacking. Details at How to show google.com in an iframe?

EDIT after the 1st comment below: I assume you want to load the iframe inside the dialog when "New Dialog" button is clicked. Can you try doing this:

last=$(<div/>").dialog(dialogOptions).dialogExtend(dialogExtendOptions).load("https://www.html5rocks.com/en/tutorials/cors/");

Updated fiddle : https://jsfiddle.net/rwk1Ljcy/1/

Upvotes: 1

Related Questions