Firefox re-posts to iframe on refresh of page
I'm POSTing to an iframe. In Firefox, if the user refreshes the page after the POST, the browser tries to POST again (c开发者_运维百科ausing the re-post Confirm to appear).
This only happens in Firefox (I've tested Chrome, Safari, IE8 & 7).
I've tried deleting the iframe on unload and always creating the iframe anew each time the page loads (using a unique id/name). But Firefox persists in POSTing.
Anyone have a clue?
When you refresh, Firefox tries to refresh the current page in all frames, rather than setting them back to their original pages.
Once you have posted to the frame, can you not then load another document into the frame, thus replacing the posted document? Or maybe only create the frame when you need to post to it.
I had same problem and I found that Firefox loads removed iframe location in next iframe, I put it as last iframe in body so that there was no iframe after it!
Set name for your iframes and call this method as body onload to check your iframe locations:
function debugframes() {
if(confirm("Show " + window.frames.length + " iframes?")){
for(var f = 0; f < window.frames.length; f++){
alert(window.frames[f].name + "/" + window.frames[f].location);
}
}
}
I'm still looking to find a better way to solve this problem, I will post if I find.
Edit: You can also do document.getElementById("iframe-id").src = "";
before reloading the page (not removing iframe).
精彩评论