Home
> Uncategorized > IFrames and the back button
IFrames and the back button
If you have an Iframe on a page, and you press the back button, then oftentimes, only the Iframe goes back in it’s history, not the containing page.
There are a few workarounds for this, this is just a proposal, if it helps…
firstly, if you have a pre-loader on the iframe, such as…
graph.contentWindow.document.write(‘Please wait…’);
graph.src = ‘someurl’
graph.src = ‘someurl’
when you can poll the Iframe for a change in the "Please wait message". (Note, that the url that you are redirecting to must be on the same domain as the parent page, or else you get a security exception)
// 951 – back button fix.
var wasGraphLoaded = false;
setTimeout(‘checkGraph()’,500);
function checkGraph()
{
if (imgGraph.document.body.innerHTML.indexOf("…")==-1)
{
// Graph must be loaded…
wasGraphLoaded = true;
}
else
{
// Graph isn’t loaded.
if (wasGraphLoaded)
{
// The back button bust have been pressed
window.history.go(-1);
}
}
setTimeout(‘checkGraph()’,500);
}
var wasGraphLoaded = false;
setTimeout(‘checkGraph()’,500);
function checkGraph()
{
if (imgGraph.document.body.innerHTML.indexOf("…")==-1)
{
// Graph must be loaded…
wasGraphLoaded = true;
}
else
{
// Graph isn’t loaded.
if (wasGraphLoaded)
{
// The back button bust have been pressed
window.history.go(-1);
}
}
setTimeout(‘checkGraph()’,500);
}
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback