In HTML ,
if I do this ->
<iframe src="https://www.youtube.com/"></iframe>
or,
<embed src="https://www.youtube.com/"></embed>
or,
<object data="https://www.youtube.com/"></embed>
it shows me an error { Refused to display 'https://www.youtube.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'. }
and says youtube.com refused to connect.
can I get rid off?
Is there any way to show youtube homepage to my website iframe or embed or object element?
Good try, normally you can indeed add a site with iframe in your own site like:
<iframe src="https://yoursite.com/" " width="100% " height="600 "></iframe>
Websites like youtube can use x-frame options or a content security policy to check if other website may embed them on their own page.
This is an important security feature to prevent clickjacking, which is an attack that allows malicious sites to trick users into clicking links on a site. source
You should always read the docs first:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
You cannot embed youtube.com directly in an iframe, because the setting X-Frame-Options: sameorigin only allows embeddings on websites which run on the same domain (in this case youtube.com).
What you can do instead is embedding the YouTube player: https://developers.google.com/youtube/player_parameters