0

On my aspx page, I have a tab control. In each tab I am loading an Iframe with URL. This Iframe URL is stored in a db table. Each tab has its own Iframe. Tabs are generated dynamically by reading a data in a table. When focus is on Iframe and user presses back button, it tries to load previous url in Iframe and gives 404 error. How can I handle this backspace button case? Same thing happens when user click browser back button.

I tried capturing KeyCode on keydown event in javascript and set window.location.href to the same page.

This works well on parent page. But when focus is on tab content, I dont have any control over there.

Also for my parent page, I am disabling cache on Page Init event by

protected void Page_Init(object Sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
} 

Is there any way to handle these two scenarios?

Akash Amin
  • 2,741
  • 19
  • 38
Lokesh
  • 137
  • 2
  • 12
  • Window `keydown` event can be prevented using `preventDefault()` but it is not a good idea to hack browser back button functionality – Anupam Jun 21 '16 at 11:32
  • You can use [onbeforeunload] (https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload) – GH Karim Jun 21 '16 at 11:34

0 Answers0