views:

23

answers:

1

Hi Does anyone have a script or know how to load iframe content content after the rest of the page has loaded.

Thanks in advance ashley

+2  A: 

JavaScript

window.onload = function() {

    document.getElementById('my-iframe').src = 'http://www.example.com';

};

HTML

<iframe id="my-iframe">It's 2010, GTFO!</iframe>

BTW, please don't use that alternate content in the example above :P

For the jQuery lovers out there too...

jQuery

$(window).load(function() {
    $('#my-iframe').attr({ src: 'http://www.example.com' });
});
alex
The alternate content WILL get indexed by crawlers; most search engines show a short page preview. Therefore, you'll get a text telling the users to GTFO, in the search results. I wouldn't expect anyone to click on such result ;)
Piskvor
@Piskvor Yeah I realised that, hence my disclaimer :P
alex

related questions