I try to recover width and height of an iframe dynamically to attribute they're values on variables which will are use to adapt another element on the size at the iframe on the loading of the page.
I have this error in the console :
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
});