I have a website in ASP.NET.
After page load, I am getting below error.
Error: Load denied by X-Frame-Options: http://www.youtube.com/v/lgZBsWGaQY0&feature does not permit cross-origin framing.
Due to this error, youtube video is not able to open in iframe.
<div style="display: none; position: relative;">
<div id="divYouTubeClasses">
<iframe id="Iframe1" style="background-color: White !important; border: 0;" width="835"
height="430" src="http://www.youtube.com/v/g5RM5StrMXY" scrolling="no"></iframe>
</div>
</div>
Please provide some solution for this error.
YouTube Urls must be cleaned and normalized before inserting them into an iframe. Here is my Common js compliant library I created to clean and normalize YouTube urls.
Updated to accommodate YouTube Mobile urls. ie: m.youtube.com Updated to get images as well, and protect against GET vars in the url
These steps will make you understand how it is done :
You can see well here that the url is generated by /embed which goes with the first ansewer.
Original URL in Query
Expected URL