why $(window['iframeName'].document.body).html() doesn't work when i change .attr('src')

why $(window['iframeName'].document.body).html() doesn't work when i change .attr('src')

why $(window['iframeName'].document.body).html() doesn't work when i change .attr('src')

when i set the src attribute of iframe to any url when i creating the page, this code $(window['iframeName'].document.body).html() will work.

but when i change the src attribute by .attr('src',"www.google.com.sa") and wait to load the page, $(window['iframeName'].document.body).html() will doesn't work.

Where is the problem ?