2013-11-01 78 views
0

我試圖插入一個由視頻主機提供的cookie,該視頻主機將恢復用戶離開的視頻。他們有一個很明顯的例子。當試圖將其插入到我的Drupal站點時,該cookie將不起作用。視頻剛開始時就會重新開始。如何將我的JavaScript插入到我的Drupal站點/節點

我已經啓用了「PHP輸入過濾器」,因爲我讀到我需要爲drupal插入腳本。請參閱下面我節點中的代碼。

任何人都可以幫助我找出爲什麼這不起作用,如何讓它工作,或者用Drupal做到這一點的更好方法?

謝謝

<script type="text/javascript"> 

wistiaEmbed.ready(function() { 
    var all_cookies = document.cookie.split(';'), // gets the value of the cookies on the  page 
    cookie_str = "resume_video=", 
    resume_cookie = does_resume_cookie_exist(all_cookies); 


    function does_resume_cookie_exist(cookie_arr) { 
    var i, curr_string, found; 
     for (i = 0; i < cookie_arr.length; i++) { 
     curr_string = cookie_arr[i]; 
     if (curr_string.substring(0,5) === cookie_str.substring(0,5)) { 
      // we've found it! 
      found = curr_string; 
      break; 
     } 
     } 
    return found; 
    } 

    function set_cookie_time(t) { 
    document.cookie = cookie_str + t.toString(); // this takes the time (t) and sets the cookie with that time 
    } 

    if (resume_cookie) { 
    num = resume_cookie.split('=')[1]; 
    start_time = parseInt(num); 
    wistiaEmbed.time(start_time).play(); // plays the video at the specific time defined in the cookie upon return to the page 
    } else { 
    set_cookie_time(0); // places a cookie on the visitor 
    wistiaEmbed.play(); // starts the video from the beginning 
    } 
    wistiaEmbed.bind("timechange", function(t) { // on timechange, reset cookie 
    set_cookie_time(t); 
    }); 
    wistiaEmbed.bind("end", function() { // if person has watched the entire video, sets the video to beginning upon retun 
    set_cookie_time(0); 
    }); 
}); 
</script> 

<div id="wistia_npcc5k96s9" class="wistia_embed"   style="width:640px;height:508px;"> </div> 
<script charset="ISO-8859-1" src="http://fast.wistia.com/assets/external/E-v1.js"> </script> 
    <script> 
wistiaEmbed = Wistia.embed("npcc5k96s9"); 
</script>**strong text** 

回答

0

您正在使用什麼版本的Drupal?您提供的代碼是否實際在請求響應中輸出?

對此有幾種解決方案(IMO)。

希望有所幫助。

+0

我很欣賞你的意見。那麼我會把它放到我的html.tpl.php文件中嗎?此外,我將它在我的個人網站上工作(我正在使用它進行測試),所以我很興奮。然後,我將正在我的個人網站上工作的確切腳本插入到我的客戶生產站點,而不是在我客戶的生產站點上工作。視頻在我的網站上恢復完美,但在客戶網站上,它仍然在重新開始時開始。有任何想法嗎?我很樂意爲您提供兩種網址,以便您可以看到這種行爲。再次,謝謝!哦,我是D7。 –

+0

是的,也許是一個示例鏈接,我們可以看到錯誤的代碼會有所幫助。 – magicRoot

相關問題