2012-03-20 20 views
0

我想讓VibeDeck腳本自動播放。它使用HTML中的href =「#play」行來單擊調用它。自動播放幫助Javascript和Iframe

但問題是,我試圖讓父窗口重定向到#play。以及實際的iframe窗口重定向到#play。但它仍然不會自行發揮。我真的很想知道是否有任何方法可以自動爲該腳本調用播放功能。它目前位於

http://12-3.co.uk/

它是在底部的播放列表。

回答

0

您可以嘗試將onLoad="functionYouCallToStartPlaying()"屬性添加到您網站的身體標記。

或者:

<script> 
function checkIfDefaultPage(pageAddress) 
{ 
    //basically check if the user is on the homepage and you have no #play in the URL, 
    //so the URL does not become http://12-3.co.uk/#play#play 
    if((pageAddress == "http://12-3.co.uk")||(pageAddress == "http://12-3.co.uk/")) 
     return true; 
    return false; 
} 

function jsRedirect() 
{ 
    if(checkIfDefaultPage(Document.Location)) 
     Document.Location = Document.Location + "#play"; 
} 
</script> 

,同時具有

<body onLoad="jsRedirect();"> 

這可能使JavaScript重定向爲你工作。

編輯:避免Document.Location問題,您可能會重定向多次的靈感位於here

+0

我試過了,但問題是,代碼很難找到它們的功能。我不知道用什麼函數來玩。 – 2012-03-20 11:33:18

+0

更新的答案,代碼可能不是那麼可靠,但是,因爲我沒有測試過它... – 2012-03-20 13:08:57

+0

謝謝!我認爲這可能工作,但anotehr問題是框架本身使用JavaScript來調用另一個站點上的另一個腳本。並且這個Javascript調用一個iFrame位置來放置框架。有什麼辦法可以解決這個問題嗎? – 2012-03-20 23:19:01