Reputation: 1
I have a page with an iframe. I can login successfully and do some operations. But when I click the browser refresh button the whole page refreshes, which have IFrames so the IFrame refreshes with the master page and returns to the login screen. How can refresh only the Iframe page?The relevant code is
<iframe id="iframeid" src="/Home/Index?iws=www.abc.com" sandbox="allow-same-origin allow-scripts" style="width:100%;height:100%"marginheight="0" marginwidth="0">
</iframe>
window.onbeforeunload = function (e) {
document.getElementById('iframeid').contentWindow.location.reload();
};
Upvotes: 0
Views: 693
Reputation:
The only thing you can usefully do in a beforeunload
handler is return a string to prompt the user to not leave the page. Any other actions you take in the handler will be cancelled when the page is unloaded, which happens almost immediately.
If you want to allow the user to refresh the iframe, you'll probably need to create a button in your page to do that. There isn't any practical way to override the browser's refresh button.
Upvotes: 1