2012-12-17 28 views
0

在我的網站上,我希望用戶能夠在輸入欄中鍵入SoundCloud URL,然後單擊保存按鈕將輸入欄變成播放該音頻的SoundCloud音樂播放器URL。但是我在我的Chrome控制檯收到以下錯誤信息:使用SoundCloud API動態嵌入音樂播放器接收到錯誤

Unsafe JavaScript attempt to access frame with URL http://jsfiddle.net/AGcQm/ from frame with URL http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F71112492&show_artwork=true&color=434C58&maxheight=266. Domains, protocols and ports must match. 

這裏是的jsfiddle確切的代碼:

http://jsfiddle.net/AGcQm/ 
+0

感謝您報告此Colin,@ hristoyankov寫道,這是Chrome的一個已知問題。此問題已報告[此處](http://code.google.com/p/chromium/issues/detail?id=17325&can=5&colspec=ID%20Pri%20Mstone%20ReleaseBlock%20OS%20Area%20Feature%20Status%20Owner% 20Summary),你也可以爲它展示它,以向Chrome開發者展示它對你來說很煩人。 –

回答

3

這應該很好地工作:

http://jsfiddle.net/AGcQm/2/

$("#btnGo").click(function() { 
SC.oEmbed(
    $("#sndUrl").val(), 
    { 
     color: "434C58", 
     maxheight: 266 
    }, 
    $("#soundcloud")[0]); 

$("#sndUrl").hide(); 
$("#btnGo").hide(); 
}); 

編輯:我得到了和你描述的相同的警告。這似乎是一些已知的Chrome問題,但它並不妨礙代碼的正常工作。基本上,soundcloud iFrame試圖訪問父級,Chrome不允許這樣做。