2017-11-20 16 views
0

イオンフレームワークが新しく、Iframeのハードウェアのバッククリック機能を管理できません。私は特定のURLを読み込むためにIframeを使用しています。ハードウェアの戻るボタンをクリックすると、ブラウザの履歴ページに戻ることができます。しかし、ハードウェアをクリックするたびに、そのアプリを終了します。iframeのブラウザ履歴を管理するonclickハードウェアのバックボタンionic 2

`<iframe #iframe id="iframe" style="height: 100%;width: 100%;" src="your url"></iframe>` 
@ViewChild('iframe') iframe:ElementRef; 

constructor(public platform:Platform,public nav:Nav){ 

    platform.registerBackButtonAction(() => { 
    if(this.nav.canGoBack()){ 
     this.iframe.nativeElement.contentWindow.history().back(); 
    } 
    }); 
} 

答えて

0

あなたはwindow.history.back()を使用することができます。この方法について

ionViewDidLoad() { 
    this.navBar.backButtonClick = (e: UIEvent) => { 
     window.history.back(); 
    } 
    this.initializeBackButtonCustomHandler(); 
    } 

    ionViewWillLeave() { 
    // Unregister the custom back button action for this page 
    this.unregisterBackButtonAction && this.unregisterBackButtonAction(); 
    } 

    initializeBackButtonCustomHandler(): void { 
    this.unregisterBackButtonAction = this.platform.registerBackButtonAction(function(event){ 
     window.history.back(); 

    }, 101); // Priority 101 will override back button handling (we set in app.component.ts) as it is bigger then priority 100 configured in app.component.ts file */ 
    } 

詳細情報hereを見つけることができます。

関連する問題