Q695 Posted November 3, 2013 Share Posted November 3, 2013 I have this line of code, but it's redirecting to another page, but I want it to replace the freeze frame of the video: document.write("<iframe width='420' height='315' src='//www.youtube.com/embed/...' frameborder='0' allowfullscreen></iframe>") What does the document.write need to say to swap, and not go to another page? Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted November 3, 2013 Share Posted November 3, 2013 The document.write is adding an iframe to the webpage. It is the requesting the webpage you have defined in the src attribute ( src='//www.youtube.com/embed/...'). Quote Link to comment Share on other sites More sharing options...
Q695 Posted November 5, 2013 Author Share Posted November 5, 2013 Yes, but it's going to its own page, but I want to trigger the video to load in the current page similar how a mssenger updates when you send an im to the server, but on the client side as a click.. Quote Link to comment Share on other sites More sharing options...
Q695 Posted December 12, 2013 Author Share Posted December 12, 2013 Any ideas? Quote Link to comment Share on other sites More sharing options...
nogray Posted December 12, 2013 Share Posted December 12, 2013 If you use document.write after the page has loaded, it will rewrite the entire page. Instead, use innerHTML of an html element. e.g. <div id="my_video_div"></div> ... later in your script ... document.getElementById('my_video_div').innerHTML = '<iframe ....>'; Quote Link to comment Share on other sites More sharing options...
Q695 Posted December 14, 2013 Author Share Posted December 14, 2013 I think I can figure it out now Quote Link to comment Share on other sites More sharing options...
Q695 Posted December 15, 2013 Author Share Posted December 15, 2013 Now I have this code: <script> <?php if ($_GET['item']){ echo " function show_video($video_name, $video_value) { document.getElementById('video').innerHTML='$video_name'; document.getElementById('video').href='$video_value'; document.getElementById('video').target='_blank'; } "; } ?> </script> errors as undefined php variables. After this I will rewrite it to swap an image (1st) with a video (2nd). Quote Link to comment Share on other sites More sharing options...
Solution Q695 Posted December 18, 2013 Author Solution Share Posted December 18, 2013 The values of the button should be: <input type='button' onclick='show_video(w3c, w3c.org)' value='Watch'> It really outputs: function show_video(, ) { document.getElementById('video').innerHTML='$'; document.getElementById('video').href='$'; document.getElementById('video').target='_blank'; } </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.