Why is my iframe video disappearing?

大兔子大兔子 提交于 2020-01-17 08:31:40

问题


I'm still a php beginner...I searched for someone with a coding issue like mine but could not find specifically what I was looking for. I apologize if somehow I missed an identical post somewhere.

I have a php generated list of top 10 videos (listed by titles). The list (which is correctly ordered and is generated from a foreach loop) of titles is anchored per title to a sample video in a specific location of the html portion of the page, specifically in an iframe. When the user clicks on the titles of the videos, the sample YouTube video plays in the correct location with no problem, even when the iframe has a 'name' assigned to it. However, as soon as the 'target' attribute (bolded below) is added to the php code, referencing the 'name' of the iframe, the correct video loads for about 1 second, and then disappears, leaving in its place a portion of the home page of my site (iframe dimensions are much smaller than whole page). Here is the code:

<html>
<div id="iframe_play"> <!--Start iframe-->
<iframe name="iframe1" width="558" height="325"    
src="http://www.youtube.com/embed/MAFzWFHmXiw" frameborder="0"></iframe>
</div>
.
. //Some code
.
<td class="class1"><?php 
echo "<ol style=\"list-style:none; margin: 0; padding: 0\">";

$i = 1; 
             foreach ($videos as $video) {

                if($i>10){
                break; //Necessary to terminate loop properly
                        }

             echo "<li style=\"margin-left:20px\"><font size=2   
             style=\"color:red\">".$i."</font>"."&nbsp;&nbsp<a href=\"#null\" 
             **target=\"iframe1"** onclick=\"activatevideo();\"><font size=2 
             style=\"color:#23B223\">".substr($video['title'],0,23)."</font></a></li>";

$i++;

                   }
echo "</ol>";

?></td>

</html>

I should add that it would be gravy to 'target' selected sections of the page, but if for some reason I cannot accomplish this I will live with omitting the target=\"iframe1". Can someone please explain this disappearing sample video within the iframe only when using 'target'?

来源:https://stackoverflow.com/questions/18685992/why-is-my-iframe-video-disappearing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!