3

I have a form inside an iframe. As soon as the user saved the data I redirect the iframe to a page that does nothing more than reloading the main page (as some other content depends on what was inserted inside the iframe). So the data outside the iframe ist updated and the form should appear again.

The problem: at least firefox (haven't tested it in other browsers yet) keeps the "new" url of the iframe with the redirected page and not the one that is set by sourcecode. Something similar to autocompletion with input fields.

I do the reload by

parent.location.reload();

Is there maybe a way to force a real reload without keeping any information from the history of the containing iframes?

btw: I may use jQuery if it helps.

Thanks.

asked Jul 21, 2013 at 16:46

2 Answers 2

1

You could try something along these lines (http://jsfiddle.net/AKykZ/):

document.querySelector('button').addEventListener('click', function() {
 document.querySelector('iframe').setAttribute('src', document.querySelector('iframe').getAttribute('src'));
 window.top.location.reload();
 return false;
}, false);

In the fiddle, click the link in the iframe, and hit the reload button. It sounds like you're reloading from the iframe, but this should at least get you on the right track.

answered Jul 21, 2013 at 16:55
Sign up to request clarification or add additional context in comments.

7 Comments

What are you trying to achieve? It sets the src to the current src so shouldn't change anything. Or am I missing something?
If you click the link in the iframe, and hit the reload, it goes back to the original src, as that doesn't get updated within the html.
Ah ok, I gonna give it a try
unfortunately doesn't solve it. The src is the correct one when I alert it (the form-url) but when the reload is finished, the iframe still has the reload-url loaded. It's probably a feature :)
You could try to do the reload when the load event for the iframe fires? Otherwise I'm out of ideas until I decide to make my own demo... :)
|
0

Found the solution. It is pretty funny but doing the reload by

parent.location.href = parent.location.href;

makes a fresh reload of the page without keeping the history. Haven't tested it in other browsers though.

answered Jul 21, 2013 at 17:16

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.