簡體   English   中英

如何在iframe上導航更改主網址?

[英]How to change main URL in reason of navigation at iframe?

我嘗試了此操作,但用戶需要兩次單擊“后退”按鈕,一個按鈕更改哈希值,另一個按鈕更改iframe內容:

(TypeScript)

this.iframeApp.load(() => {
    if (this.sameDomain()) {
        window.location.hash = this.iframeApp[0].contentWindow.location.toString();
    } else {
        window.location.hash = this.iframeApp.prop('src');
    }
});

在開始時:

var url = window.location.hash;
if (url.length > 1) {
    url = url.substring(1);
} else {
    url = this.settings.default;
}
this.openPage(url);

我認為History Api將無濟於事。 我需要可以在IE9上使用的功能

嘗試這個:

this.iframeApp.load(() => {
    if (this.sameDomain()) {
        window.location.replace(window.location.toString() + '#' + this.iframeApp[0].contentWindow.location.toString());
    } else {
        window.location.replace(window.location.toString() + '#' + this.iframeApp.prop('src'));
    }
});

通過使用replace()方法,您無法返回到先前的URL,因此您的用戶只需要按一下“后退”按鈕一次。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM