リワード表示設定
15 4月, 2023Leave a review – Judgeme.io
13 12月, 2023BON Loyaltyウィジェットとシングルページアプリケーション(SPA)
SPA(シングルページアプリ)では、ログイン・登録後にページが自動でリフレッシュされない問題があります。 BONの認証はサーバー側で実行されるため、ページを更新しない限り反映されません。
以下の回避コードを実行することで、BON LoyaltyウィジェットがSPAでも正しく機能するようになります。
お客様がサイト上でログイン/登録に成功した後、以下のコードを実行してウィジェットを再初期化し、BON Loyaltyウィジェットと認証情報を同期させてください。
function createjscssfile(filename){
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
return fileref
}
function replacejscssfile(oldfilename, newfilename){
var allsuspects=document.getElementsByTagName("script")
for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
if (allsuspects[i] && allsuspects[i].getAttribute("src")!=null && allsuspects[i].getAttribute("src").indexOf(oldfilename)!=-1){
var newelement=createjscssfile(newfilename)
allsuspects[i].parentNode.replaceChild(newelement, allsuspects[i])
}
}
}
window.bonRender = false;
replacejscssfile("https://d31wum4217462x.cloudfront.net/app/bon-loyalty.js?v=3.2.0", "https://d31wum4217462x.cloudfront.net/app/bon-loyalty.js?v=3.2.0" + new Date().valueOf()) //Replace all occurences of "oldscript.js" with "newscript.js"