How to use a heroku app inside a html iframe? - html

I want to use this heroku app (spring boot) inside an iframe. https://sef-github-leaderboard.herokuapp.com/ but it doesn't work. it says refused to connect. Here's the code.
<!DOCTYPE html>
<html>
<body>
<iframe src="https://sef-github-leaderboard.herokuapp.com/" title="Iframe Example" style="height:500px;width:100%;"></iframe>
</body>
</html>

If you open up devtools, click the Network tab, refresh the page, and click the first item in the waterfall, you'll find that the Content Security Policy header X-Frame-Options is set to DENY on the URL you are seeking to embed. This instructs the browser to disallow loading the page within an iframe. To get around this, you would need to use a forward proxy to strip out the headers.

Related

Unable to load an URL using iFrame because of Content Security Policy

<!DOCTYPE html>
<html>
<body>
<iframe src="URL">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>
I am using the above code to load the url inside iFrame and i am getting below error:
Refused to display 'URL' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors https://inteliapp-stage.grymatter.com URL1 URL2 URL3 URL4 URL5 URL6 URL7
http://18.233.166.250 https://18.233.166.250 cdn.jsdelivr.net".
For security reason, i am not able to mention the exact URLs. I want to know what should i add inside meta tag for content security Policy to resolve the problem? If we cant resolve the problem then how we can load the url inside html code.Please help me out. Thanks in advance.
The page you're trying to put in the frame has the policy that's being violated. There isn't any way to weaken CSP rules once sent; so unless you can modify the source of the framed page, there's not much you can do here.
You may be able to use an alternate method, such as doing an HTTP call in the background to fetch the content of that page, and manually insert that content into your page.

How do I use the HTML IFRAME element to embed content?

<!DOCTYPE html>
<html>
<head>
<title>My favorite app</title>
</head>
<body>
<iframe src="https://stackoverflow.com/questions/36047483/parsing-a-websites-
html-tags-in-iframe"></iframe>
<div class="title">My App</div>
<div class="app">
<div class="image"><img src="images/app.png" alt="this is a
screenshot" class="image"></div>
</div>
</body>
</html>
i tried to use iframe tag but it doesn't work and a blank section is appeared as that image.
the blank section that appears to me in the browsers.
That's because Stack Overflow disallows use inside a frame by setting X-Frame-Options to sameorigin...
So only is allowed as iframe inside Stack Overflow itself, not from your code.
Long version:
When your browser try to access that URL from Stack Overflow, Stack Overflow returns some headers, one of them is X-Frame-Options: sameorigin, that instructs your browser to disallow to display that URL inside an IFrame, so your browser refuse to do it.
Its a SO server config (you can't do anything about it).
The Stack Overflow page you reference in the src attribute is not displayed in the iframe element because the Stack Overflow site implements an iframe blocking policy. In order to do this, it uses the X-Frame-Options. (See also how to block website from loading in iframe?.)
You can check whether a site implements this policy by inspecting its HTTP headers. For example, in Firefox, press F12 to open the inspection tools, then go to Network, select one of the objects that were sent over HTTP and look at the headers (or filter the headers for e.g. "x-frame"). Below is what this looks like for the URL you tested:
Notice x-frame-options: SAMEORIGIN in the lower right part of the screenshot. With x-frame-options: SAMEORIGIN or x-frame-options: DENY set on the server side, you will not be able to load pages from that site inside an iframe or a frame.
For more background, see X-Frame-Options – How to Combat Clickjacking, which also explains other values that can be used in the x-frame-options header.
If you want to test with a webpage from a server that does not block loading in iframes, try for example https://wiki.archlinux.org/index.php/Tomcat.

html containing iframe won't display in browser

I want to embed a video stream in a html page. I run apache on a raspberry pi. With the standard index.html it works fine. When I change to my custom index.html, it says the page takes too long to load. This occurs when I access from another network (the internet) not the local network.
This is the content of the html page:
<html>
<head>
</head>
<body>
<iframe src=”http://192.168.1.56:8081” height=”480” width=”640”>
</iframe>
</body>
</hmtl>
My research has led me to X-Frame-Options (this is the best reference https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options i found).
I have enabled the headers module
a2enmod headers.load
systemctl restart apache2
and added the following line at the end of the apache2.conf file
Header always set X-Frame-Options “ALLOW-FROM http://192.168.1.56:8081”
Could you please help?
Thanks!`

Auto refresh in Mac not working for some site

I got a code that refreshes the html page as per the seconds I desire. I am on an Mac and I use the TextEdit app to make the HTML file. This code works for www.apple.com but it does not work for say, https://www.bitcointalk.org or http://www.macrumors.com.
I am not sure why this is happening. All I am doing is replacing the apple URL with bitcointalk url. I know I can also do this refreshing via Safari extension, but I need this code to work.
Thanks a lot
The code I am using is:
<html>
<head>
<meta http-equiv="refresh" content="5">
</head>
<FRAMESET>
<FRAME src="http://www.apple.com/">;
</FRAMESET>
</html>
EDIT: What I am trying to do is, create this html and move it to my iPhone, so that I can do the web refresh through my phone. Right now there are only paid apps in the App store that lets you refresh a page automatically every few seconds/minute and they are not really that good.
As #esqew pointed out in their comment, the sites that aren't showing up forbid access via frames by setting the X-Frame-Options HTTP header to DENY or SAMEORIGIN.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options

Access anchor tag attribute inside iframe

Parent domain: www.parent.com
Iframe domain: www.iframe.com
<html>
<head></head>
<body>
<iframe id="trick" src="www.iframe.com/test">
<html>
<head></head>
<body>
test
</body>
</html>
</body>
</html>
Question: how to access the value of href of anchor tag inside iframe using jquery?
Since they pages appear on different origins:
The page containing the frame needs to listen for a Message event.
The page inside the frame needs to send a message using postMessage.
This, obviously, requires changes on both sites. Explicit co-operation between the sites is required for obvious security reasons (if they aren't obvious, imagine your bank's website being loaded in an iframe by a random site you visited via Google).
Check this link: http://simple.procoding.net/2008/03/21/how-to-access-iframe-in-jquery/
$('#iframeID').contents().find('#someID').html();