2015-11-01 51 views
2

我在WordPress中有一個非常簡單的頁面,它在WordPress框架之外運行良好,但是一旦我將它集成到WordPress主題中,它就拒絕重新調整元素的大小。函數的其餘部分執行OK,但調整大小將被忽略。在WordPress中通過Javascript動態調整大小

有沒有什麼特別的關於讓Javascript的WordPress主題工作?

function play_vid(vid,xSrc,xWidth,xHeight,xTitle){ 
    var myVideo = document.getElementById(vid); 
    myVideo.src=xSrc; 
    myVideo.style.width=xWidth; 
    myVideo.style.height=xHeight; 

    var myVideoPlate = document.getElementById('video_plate'); 
    myVideoPlate.style.width=xWidth+40; 
    myVideoPlate.style.height=xHeight+60; 

    var myVideoTitle = document.getElementById('video_title'); 
    myVideoTitle.innerHTML=xTitle; 
    myVideoTitle.style.height=xHeight+60; 


    var myElement = document.getElementById("video_plane"); 
    myElement.style.minHeight="100%"; 
    myElement.style.visibility="visible"; 
    document.body.style.overflow="hidden"; 
    myVideo.play(); 
} 

回答

0

的樣式屬性必須是有效的CSS串,這意味着你不能使用你也有編號添加測量,你缺少@height和@width。 只需添加+「px」

myVideoTitle.style.height=(xHeight+60)+"px"; 
+1

這太奇怪了,它工作在一個靜態的HTML頁面上。謝謝! – JRQ