0
我嘗試動態地恢復iframe的寬度和高度,以將它們的值設置爲變量的值,這些變量將用於調整另一個元素的大小加載頁面的iframe。動態地恢復iframe的寬度和高度,以使其內容適應良好的尺寸
我有這樣的錯誤在控制檯:
jQuery.Deferred exception: Cannot read property 'width' of null TypeError: Cannot read property 'width' of null at HTMLDocument.
HTML
<iframe src="" scrolling="no" frameBorder="0" width="640" height="360"></iframe>
jQuery的
$(function()
{
var frameEl = window.frameElement;
var widthIframe = frameEl.width;
var heightIframe = frameEl.height;
$(".mediaplayer").css("height", heightIframe + "px"); // attribute 360px
$(".mediaplayer").css("width", widthIframe + "px"); // attribute 640px
});
[返回嵌入窗口的元素(例如