2014-07-02 17 views
0

我正嘗試將vimeo視頻發佈到我的新網站的tumblr頁面上。爲此,我正在閱讀tumblr頁面的json文件中的視頻源信息,該頁面可通過http://vimeo.tumblr.com/api/read/json訪問一個網頁,而不是本地文件?

訪問,然後嘗試使用jquery將其附加到我的網頁。 但是,它看起來像鉻解釋//player.vimeo.com鏈接是一個本地目錄,而不是網站!我應該怎麼做呢?

這裏基本上是我現在所擁有的

<!DOCTYPE html> 
<html> 
<head> 
<meta charset=utf-8 /> 
<title></title> 
<div id="helloWorld"></div> 
<script type="text/javascript" src="Karen/jquery.js"></script> 

<script type="text/javascript" src="http://vimeo.tumblr.com/api/read/json"> 
</script> 
<script type="text/javascript"> 
for (var i=0; i<5; i++){ 
     var link = tumblr_api_read.posts[i]["video-source"] 
    $("div#helloWorld").append(link + "<br>"); 
} 


</script> 

</head> 
</html> 

編輯:對不起任何混亂,我試圖解決我所面臨當視頻源都被包裹在iframe的問題,並造成瀏覽器找文件://player.vimeo.com ....

我能夠這樣做

var link = tumblr_api_read.posts[i]["video-source"]; 
    if (link){ 
    link = link.replace("//player", "http://player") 
    $("div#helloWorld").append(link + "<br>"); 
    } 
+0

什麼不工作?可以使用清理。但是你的代碼工作。 http://jsfiddle.net/psradich/6VuhJ/ –

+0

對不起,我實際上是使用不同的tumblr與iframes作爲視頻源,但是出於隱私原因而改變它,但不知道它們是不同的。 – Kei

+0

啊。不知道我可以幫助至少得到一個類似的來源 –

回答

1

//要解決的問題是相對的:它會指向使用p rotocol,適合當前的任務:如果您在本地測試此網頁,//總是會指向file://。如果您在線執行此操作,則它將使用http://https://,具體取決於您正在訪問的資源的協議。

要解決這個問題,只需明確您想要使用的協議,可以是httphttps

相關問題