2013-07-25 62 views
0

一个简单的Hello World功能和一个说明错误的按钮。将iFrame评论一下 - 像魅力一样。删除评论 - 致命错误。我感到困惑。添加iFrame后无法找到功能

来源:

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
    <meta charset="utf-8" /> 
    </head> 
    <body> 
    <button onclick="helloWorld()">Click me</button> 

<iframe id="ytplayer" type="text/html" width="640" height="390" 
    src="http://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&origin=http://example.com"/> 
</body> 
</html> 
<script> 
    function helloWorld() { 
     console.log("Hello world"); 
    } 
</script> 
+3

为什么脚本元素放置在那里?将其移动到''中。 – Jon

+0

将函数移动到HTML的头部部分 –

+4

使用正确的iframe语法。 '