Browser history with iframes on page - iframe

I have a page with some links and a few iframes. When the user clicks on any link the content is loaded in iframes. Now I want to integrate it with browser back button. In order to achieve this what I am doing is when any link is clicked I change the window location hash and then listens for onhashchange event. When the event fires, it is handled and looking at the hash value I(restore the state and) load the content in iframes. For loading the content in iframe I use window.location.replace() method to prevent it from appearing in the history and interfere with working of back button. Is there a better approach that can be taken to achieve the above functionality? Please note that removing iframe is NOT an option. Any help is appreciated.

Why don't you just use the iFrame's history? As it is a seperate context and it's own web browser in a way, it has it's own history.
Try:
document.getElementById('id_Of_ Iframe').contentWindow.history.back();

you can have a button like this
input type="button" onClick="history.back()" Value="Back"
Hope it will help.

Related

How to get updated iframe source

How can i get the updated iframe src value after my user navigates throught the site that is inside the iframe?
I'm asking this because the src value is always the same! It don't change even if you navigate inside the iframe.
Thanks
easiest way is to use javascript to dynamicly refresh the <iframe> by setting the src to a given interval refresh rate.
Have a look at the below example
dynamicly refresh iframe without refreshing current page

Backbone Project, How to navigate back when there is a iframe within the view?

How to navigate back when there is a iframe within the view?
After user clicks on a link to other pages from within the iframe, the browser history gets append on to it as well so that I cant use "window.history.back()" to go back, since "-1" will take user back within iframe and not the actual app itself.
What is a good way to solve this so that when back button pressed its the previous "route" and not the history of iframe history?
try doing something like this, from the Iframe:
window.top.history.back();
or
back to backbone app
This way you are accessing the Iframe's parent window history, not the Iframe itself. As long as you navigate to the Iframe from your SPA, this should work.

Clear the browsing history on submit button click

I have a page with a about 200 controls on it and Submit, Close , SavenClose and Cancel buttons. My requirement is to clear the browsing history once any of these buttons are clicked.
As of now I am redirecting the users to the Home Page once any of these buttons are clicked where the users can click on GoBack on the browser and come back to main page which I dont want to .
Can anyone help me achieving this , probably give me a start up code pls.
Thank you.
You can't
This functionality is specifically within the browser's domain, and can't be accessed via javascript. It is for this reason many banks and organisations log you out when clicking 'back'.
You can however request the browser to not cache your pages, so clicking back will result in a "Cannot find this page - you need to refresh" message, this may be a suitable solution for you and is widely used.
I'm not sure but I think it's not possible to have control over a user browser functionality like "delete history".
You could add this javascript on the top of each webpage:
window.history.forward(1);
The user's browsing history is theirs to control. The best you can do is ask to close the tab via Javascript on the page after they submit. You can do this via window.close()

Dynamic web user control problem when browser's back button is clicked

I have an .aspx page in which I dynamically add web controls to a panel.
The problem is when I hit the browser's back buton, it's displayed a version of the page that no longer exists on the server-side, because the controls are dynamically added.
Let's say my aspx dynamically adds Control1. From there, I click a button that loads Control2.
At this moment, if I press the browser's back button, it will display the page with Control1, but Control1 no longer exists on the server-side, so if I interact with it, some erractic behaviour will occur. Any ideas on this?
Thank you very much.
Have you tried setting the client side to not cache pages - stick this in your page load:
Response.Cache.SetCacheability(HttpCacheing.NoCache)
(Think the syntax might be slightly off, but you should be able to figure it out)
Have you tried with removing temporary files and restarting browser. Your page might be cached in browser.

ASP.NET, Showing Loading message while Postback

I have an ASP.NET page which has an asp.net button control in it. When the user clicks on the button, the page will do some calculations and then close itself, but when I click on the button during post back, the page shows a blank screen. I want to show a loading message instead of this. I used javascript to show a div which was hidden intitially and shown when the user clicks the button, but when the post back happens, the screen becomes blank. Any idea how to show the loading messsage in this scenario?
Thanks in advance.
Do you really need to avoid ASP.NET ajax or JQuery?
If so: move the heavy processing into an invisible IFRAME. Action your form to the invisible IFRAME, or use javascript to set the location of the IFRAME.
Your 'loading' javascript will display fine. When the form inside the IFRAME completes it just needs to output some javascript to tell the 'parent' to go to location or refresh.
If you use Ajax to post back to the form asynchronously, you can use the UpdateProgress control. Here is a link to an article explaining how to implement the functionality:
How to make a Gmail-like loading indicator with ASP.NET Ajax
Basically, you can't using just postbacks. The browser draws the screen white while waiting for a response from the server. That message you set to show when the user clicks a button was the correct approach (so good work).
But the browser drew the screen white, thinking "Oh boy I'm about to get a response!" and then waited for longer than you think is appropriate.
The only thing you could try would be, in the response, make the very first thing to stream to the browser some sort of loading message that the browser can display while loading the rest (like the gmail loading screen). But personally, I think you could spend your time doing some other development.
You could try other techniques with AJAX though.

Resources