我很新的JavaScript。在HTML代碼中使用JavaScript變量
我試圖製作一個YouTube 2.0 html的東西,(有趣的學習經驗)。我希望能夠點擊「加載視頻」鏈接,並要求您鏈接到實際的YouTube視頻。然後,當您粘貼它時,它會在頁面上顯示視頻。
我的代碼是
<h1 style="background-color: red; color: white; font-family: helvetica; padding: 20px 20px 20px 20px;">Youtube 2.0</h1>
<a href="#" onclick="openVideo()">Load video</a>
<script>
\t var theVideoLink;
\t
\t var openVideo = function() {
\t \t var videoLink = prompt("Video link on YouTube.com");
\t \t theVideoLink = videoLink;
\t };
\t
\t window.onload = function() {
\t \t document.getElementById("myLink").innerHTML=theVideoLink;
\t }
</script>
<iframe width="1120" height="630" src="myLink" frameborder="0" allowfullscreen></iframe>
如果你對我如何可以插入JavaScript變量到我的IFRAME SRC標籤的任何想法,請告訴我。謝謝!
的Youtube 2.0。 ?什麼是* 2.0.-ish *在你的代碼中?另外,如果您指的是https://developers.google.com/youtube/2.0/developers_guide_protocol,則我的問題是:您是否打開了該頁面? –
它實際上並不是YouTube 2.0。我就是這麼稱呼的。這不是一個商業項目,我只是在亂搞。 – RugbugRedfern
'width =「1120」'......不。歡迎來到響應時代。使用CSS樣式表,使用'%'或其他響應單元。避免使用內嵌'樣式' –