使用 iframe 的联合会话历史向后导航

joint session history backward navigation with iframes

我正在尝试调试我的应用程序的导航问题。问题在于通过页面上的 iframe 向后导航。

我在 SPA cordova 应用程序中使用 backbone 路由器,在 iOS 上进行测试。我的一些应用程序页面包含加载网络上托管的网络内容的 iframe。在浏览器上测试时我没有问题。在 iPhone 上,我发现通过内容 iframe 历史记录向后导航不会影响 iframe 当前文档。换句话说,后退按钮不会导致 iframe 返回。内容没有改变,window.location.href 也没有更新。有趣的是,我最终将 iframe 的历史记录条目和 return 弹出到应用程序页面历史记录,这就像一个魅力。

使用相同的设置创建精简的原型但没有我编写的插件和应用程序模块,效果很好。我需要确定,在调用历史记录 api 时,什么可能导致 iframe 无法更新其内容,而联合会话历史记录继续为父文档工作

此行为是包含 console cordova plugin (org.apache.cordova.console) 的副作用。它是一个用于重定向控制台输出的插件。

这是实现该功能的一个文件

#import "CDVLogger.h"
#import <Cordova/CDV.h>

@implementation CDVLogger

/* log a message */
- (void)logLevel:(CDVInvokedUrlCommand*)command
{
    id level = [command argumentAtIndex:0];
    id message = [command argumentAtIndex:1];

    if ([level isEqualToString:@"LOG"]) {
        NSLog(@"%@", message);
    } else {
        NSLog(@"%@: %@", level, message);
    }
}

@end

这里没有任何证据确凿,因此初始化过程中可能还有其他问题有待发现。但是,删除插件会清除副作用,我可以继续前进。

我确实挖掘了一些有趣的文章。 http://khaidoan.wikidot.com/ on the nuances of adding iframes to the page and techniques for affecting specific kinds of history recording. And chromium's implementation 进程外 iframe。

http://www.chromium.org/developers/design-documents/oop-iframes