0

I have a page which contains an iframe.

My problem is that I sometimes need to modify the iframe's page but the changes are not showing on the main page unless I go to that frame and reload it manually.

Is there a way to refresh the iframe when the page loads or similar way to sort this problem?

asked Mar 5, 2012 at 11:48

3 Answers 3

2

You could do on document ready:


$(document).ready(function() {
 $('#your_iframe_id').attr( 'src', function ( i, val ) { return val; });
});

Did you mean like that

answered Mar 5, 2012 at 11:54
Sign up to request clarification or add additional context in comments.

Comments

0

Re-setting the src attribute of the iframe is sufficient to cause it to reload. For example:

$(function() {
 $('#idOfIFrame').attr('src', 'http://yourDomain.tld/yourPage');
});

Will cause the iframe to load http://yourDomain.tld/yourPage.

Alternatively, if the iframe src is on the same domain as the outer page, you can trigger a refresh by the following:

document.getElementById('idOfIFrame').contentDocument.location.reload(true);
answered Mar 5, 2012 at 11:53

Comments

0

Providing the iframe is on the same domain as the parent page, the following JavaScript will perform a reload:

document.getElementById('iframeID').contentDocument.location.reload(true);

You can use that whenever you need to refresh it.

answered Mar 5, 2012 at 11:55

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.