2016-06-30 6 views
0

を期限切れ。私が直面している問題は、アクセストークンが30〜60分後に期限切れとなり、ページが更新されるまで認証されないということです。だから私は、ページを更新し、セッションストレージにはiframeの現在のURLを格納するためのコードを書いて、リロードにIFRAMEのSRCにそのURLを入れました。トークンが期限切れになるまで、これはすべて動作し、ページは常に元のiframeソースに移動します。これはコードです:は、後のiframe srcを設定しないトークン私は、認証するためのAzure ADを使用してウェブサイトを持って、そのサイト内私も認証するために、AzureのADを使用していますインラインフレームを持っている

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> 
<script> 
document.domain = 'company.com'; 
if (sessionStorage.getItem('url') == null) { 
window.location; 
} else { 
document.getElementById("MSOPageViewerWebPart_WebPartWPQ2").src = sessionStorage.getItem('url'); 
}; 
$(window).bind("load", function() { 
sessionStorage.removeItem('url'); 
setTimeout(refresh, 30000); 
}); 
function refresh() { 
var myURL = document.getElementById("MSOPageViewerWebPart_WebPartWPQ2").contentDocument.location.href; 
sessionStorage.setItem('url', myURL); 
top.parent.location.href = top.parent.location.href; 
}; 

</script> 

に関係なくIFRAMEがセッションストレージ内のURLに何が起こるのか素晴らしいだろうというように、誰も私まで、このコードを変更することができる方法ならば。

+0

は同じAzureのADアプリケーション内の2つのWebアプリはありますか? GaryLiu-MSFT @ –

+0

なし、彼らは異なるAzureのADアプリケーションではありません、そして、彼らは紺碧のアプリプロキシを使用しています。 – llerdal

答えて

0

問題はそれがrefresh()を発射するとき、それは最後のトップウィンドウを更新しますので、すべてのスクリプトとのDOMをリフレッシュし、初期化することであると思われます。したがって、iframeは常に元のページに移動します。

次のコードスニペットを考えてみてください:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> 

<script> 
document.domain = 'company.com'; 
if (sessionStorage.getItem('url') == null) { 
window.location; 
} else { 
$("#MSOPageViewerWebPart_WebPartWPQ2").attr('src',sessionStorage.getItem('url')); 
}; 
$(window).bind("load", function() { 
sessionStorage.removeItem('url'); 
setTimeout(refresh, 30000); 
}); 
function refresh() { 
    console.log('refresh') 
    var myURL = $("#MSOPageViewerWebPart_WebPartWPQ2").get(0).contentWindow.location; 
    console.log(myURL); 
    sessionStorage.setItem('url', myURL); 
    console.log(sessionStorage.getItem('url')); 
    // top.parent.location.href = top.parent.location.href; 
}; 
</script> 
関連する問題