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>
爲什麼腳本元素放置在那裏?將其移動到'
'中。 – Jon將函數移動到HTML的頭部部分 –
使用正確的iframe語法。 '