Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use iframe with localhost address in source ?

My HTML markup is pretty simple

....
<iframe width="800" height="800" src="http://localhost:69345/Handler.ashx"/>
...

but this page is blocked by all browser that I've used. I'm wondering is there any workaround for this issue? Surely, I completely understand that in case when my page will be deployed in production there will be no problems. However, how can I do any testing if iframe is blocked on local?

Thank you in advanced

like image 333
Disposer Avatar asked Sep 28 '12 11:09

Disposer


People also ask

Can we use iframe inside frameset?

Notice the iframe does not show up. However, if you change the frameset tag to div tag then the iframe will display.

Can an iframe be a link?

The iframe tag is used to display a web page inside a web page. When you create a document to be inside an iframe, any links in that frame will automatically open in that same frame. But with the attribute on the link (the element or elements), you can specify where the links will open.

Can you put anything in an iframe?

Iframes are most often used to embed specific content from one web page — like a video, form, document, or even a full web page — within a different web page. This is a powerful capability in HTML — you can take any content from any website (with permission) and place it on your own site to enhance your content.


2 Answers

Don't use absolute url

use relative

....
<iframe width="800" height="800" src="Handler.ashx"/>
... 
like image 81
GajendraSinghParihar Avatar answered Sep 23 '22 15:09

GajendraSinghParihar


When Chrome shows the following text in the iframe:

127.0 0.1 refused to connect

It's because the server responded with the X-Frame-Options header to DENY.

The solution is to change the server configuration so that it removes this header or sets it to SAMEORIGIN.

For example, if you're using a Django, you can either change the X_FRAME_OPTIONS setting or decorate your view with @xframe_options_sameorigin or @xframe_options_exempt.

like image 36
Benoit Blanchon Avatar answered Sep 24 '22 15:09

Benoit Blanchon