is it possible to create a website inside an website? - html

I want to load YouTube in a certain frame inside my website. I am just able to embed a particular video only. Is this possible to include YouTube inside my website in a particular frame?

You can use an iframe to achieve this but the origin website can choose to deny this.
Youtube does deny this. You would see an error like
Refused to display 'https://www.youtube.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

You can use An iframe is used to display a web page within a web page.
<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframes</h2>
<p>You can use the height and width attributes to specify the size of the iframe:</p>
<iframe src="https://www.w3schools.com/html/html_iframe.asp" height="600" width="600"></iframe>
</body>
</html>
W3Schools Reference - https://www.w3schools.com/html/html_iframe.asp
But in the case of YouTube you get an error
Load denied by X-Frame-Options: “SAMEORIGIN” from “https://www.youtube.com/”, site does not permit cross-origin framing from “https://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_height_width”
This is because YouTube has denied cross-orgin framing.
You can use https://www.youtube.com/embed/ for embedding videos.
Refer for Documentation from YouTube - https://developers.google.com/youtube/iframe_api_reference

Related

Embedding websites in html

I am trying to figure out the way this website : totallyscience.co embeds their games into the site because I am trying to make a website and I tried directly embedding a website and it isn't the same.
I tried < embed src="example.com" > and it is definitely not the same as the website listed above.
What you need here AND what totallyscience.co uses is an iframe tag
<iframe src="http://www.example.com" title="Embedding another webpage"></iframe>
You can style and position it as you need.
tip : Try to use secure links (https) in iframe. You can use a https link in a page loaded over http but not the other way.
For further reading: https://www.w3schools.com/tags/tag_iframe.ASP

How can i put my facebook's page in an iframe on any website?

<iframe src="https://www.facebook.com/MYUSERNAME/?ref=hl"> </iframe>
I've been trying this code: but it just don't work out , Kindly suggest me something here .
You can't because of security issues;
Refused to display 'facebook.com/goforazhar/?ref=hl%22%3E'; in a frame because it set 'X-Frame-Options' to 'DENY'.
Facebook denies it pages from being loaded into iFrame.
Refer "X-Frame-Options" documentation for more details;
https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options

Basic iframe Not Loading One Webpage

I am trying to load an iframe for an ESPN fantasy league into a website I made for our league members. I can load pretty much any page I want except for this one, which is a link right to our league.
<iframe src="https://games.espn.go.com/flb/leagueoffice?leagueId=27520&seasonId=2015" name="grforum" scrolling="auto" frameborder="no" align="center" height = "100%" width = "100%">
Any idea what could be causing this or how I would be able to get it to load? Thank you very much.
If you open up your JavaScript console, you'll see that the web page (ESPN) does not permit cross-origin framing - i.e. they don't allow you to load that within an iframe on your website.
Load denied by X-Frame-Options: http://games.espn.go.com/flb/leagueoffice?leagueId=27520&seasonId=2015 does not permit cross-origin framing.

iframe and external website

So I have this code:
<iframe id="theFrame" src="http://localhost" style="width:100%;" frameborder="0">
</iframe>
and the localhost site loaded in the iframe just fine..
but then when I change the src to an external website
<iframe id="theFrame" src="http://www.youtube.com" style="width:100%;" frameborder="0">
</iframe>
The website did not load.
What did I do wrong? I know that you can use external websites in an iframe since Google Image Search does so...
How can I get external sites to work in my iframe?
The reason why external websites such as:
youtube.com
google.com
stackoverflow.com
etc.
are not loading in your frame, is because they are intentionally leveraging some sort of Frame Killer.
Example (uses jQuery):
<style> html{display:none;} </style>
<script type="text/javascript">
$(document).ready(function () {
if(window.self == window.top) {
document.documentElement.style.display = 'block'; }
else {
window.top.location = window.self.location; }
});
</script>
Suggested reading:
Framekiller (Wikipedia)
Busting a tough FRAME killer
If you run the code snippet below:
<iframe src="https://www.youtube.com"></iframe>
Then look at dev tools, it will throw the error:
Refused to display 'https://www.youtube.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
This is because the site you are trying to access limits embedding (via iframe, frame, embed, object) to the same origin using the X-Frame-Options header. So youtube.com can load iframes with youtube.com pages just fine, but nobody else can. Only site admins for the embedded site can change that setting.
If you have admin for the site you are embedding, you can whitelist the the host site:
X-Frame-Options: allow-from https://my-host-site.com/
This has to be sent as a HTTP Header by the server of the page you are trying to embed. It will not work as a meta tag inside the HTML head. This is how the browser knows the site you are embedding ok'd the site that is hosting to show the page in the iframe.
You are probably experiencing the same issues I am having, Most likely the iframe is being blocked by the X-frame-options or being blocked by the Deny property. For example if you access facebook from an outside source it will come back with a DENY response in google chrome
It appears to be a youtube-only problem; src="http://www.mozilla.org" works for me in your code. If you want to display youtube videos in iframes, they'll probably want you to use "embed" option on the video page?

Embedded youtube videos blocked by network admins stopping web page loading

We've developed a website for one of our clients which has some embedded youtube videos. Unfortunately, the clients internet filtering software blocks youtube access - this cannot and will not be changed because it's their (archaic) policy.
The problem is that our client cannot load the website because it gets hung up on trying to load the embedded videos. Apparently a regular html page with a 'forbidden' message appears when someone tries to access youtube - so I would have thought the browser would give up and move on.. but no.
Does anyone have any simple suggestions as to how this can be resolved? Perhaps the 'denied' message needs to have a 403 header to get the browser to give up...alternatively is there a nice way to do this in the html?
Could you use IFrames?
<html>
<body>
<p> anything outside of the frame</p>
<iframe src="page_with_video.htm>
<p> Sorry you can't acess this</p>
</iframe>
</body>
</html>
and then you could just embed the videos on an external page, which should cause the page with the videos to load separately from the rest.