I managed to find a relatively clean easy way to do this. To see this, click on my web page: http://developersfound.com/yde-portfolio.html and hover over the link "Youtube Demos".
The following are two snippets to show how this can be done quite easily:
I achieved this with an iFrame. Assuming this DOM is "yde-home.html", which is the source of your iFrame.
<!DOCTYPE html> <html> <head> <title>iFrame Container</title> <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script> <style type="text/css">.OBJ-1 { border:none; }</style> <script> $(document).ready(function() { $('#myHiddenButton').trigger('click'); }); </script> </head> <body> <section style="visibility: hidden;"> <button id="myHiddenButton" onclick="$(location).attr('href', '"http://www.youtube.com/embed/wtwOZMXCe-c?version=3&start=0&rel=0&fs=1&wmode=transparent;");">View Full Screen</button> </section> <section class="main-area-inner" style="background:transparent;margin-left:auto;margin-right:auto;position:relative;width:1080px;height:720px;"> <iframe src="http://www.youtube.com/embed/wtwOZMXCe-c?version=3&start=0&rel=0&fs=1&wmode=transparent;" class="OBJ-1" style="position:absolute;left:79px;top:145px;width:1080px;height:720px;"> </iframe> </section> </body> </html>
Suppose this is the DOM that loads the iFrame.
<!DOCTYPE html> <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <title>Full Screen Youtube</title> <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script> <script> $(document).ready(function() {}); </script> </head> <body> <iframe name="iframe-container" id="iframe-container" src="yde-home.html" style="width: 100%; height: 100%;"> <p>Your browser does not support iFrames</p> </iframe> </body> </html>
I also tested this against the W3c Validator, and it checks HTML5 without errors.
It is also important to note that: Youtube embed URLs sometimes check to see if a request is coming from the server, so you might need to set up a test environment to listen on an external IP address. Therefore, you may need to configure port forwarding on the router for this solution to work. Once you have configured port forwarding, just check the external IP address instead of LocalHost. Remember that some routers need port forwarding from LocalHost / loopback, but most use the same IP address that you used to enter the router. For example, if your router login page is 192.168.0.1, then you will have to use 192.168.0 for port forwarding.? Where? can be any unused number (you may need to experiment). From this address you will add the ports from which the test environment will be listened (usually 80, 81, 8080 or 8088).
user2288580 Dec 06 '15 at 17:50 2015-12-06 17:50
source share