【发布时间】:2018-08-16 07:28:17
【问题描述】:
我有一个proceed to payment 按钮,它以target = _blank 重定向到redirectPayment.html 页面并在那里进行支付操作,所以一旦触发支付,我就通过本地存储将标志creditsRefresh 设置为Yes。现在,当支付成功时,它将重定向到成功 jsp 页面。所以用户可以关闭选项卡并返回开始支付的原始选项卡。但我希望在付款后刷新我的金额。因此,如果creditsRefresh 是yes,我需要在用户单击窗口时调用一个函数。我尝试做onFocus 或onBlur,它不起作用。
payment.html
<button class="btn btn-primary" ng-click="initiatePayment(CreditDetails);">Proceed to pay</button>
Paymentcontroller.js
$scope.initiatePayment = function(){
$window.localStorage.setItem('creditsRefresh','yes');
$window.open('/redirectPayment','_blank');
}
付款成功后:
$scope.myCredits是支付后刷新金额的功能。
$scope.focusOnPageCall = function(){
if ($window.localStorage.getItem('creditsRefresh') == 'yes'){
$scope.myCredits();
$window.localStorage.setItem('creditsRefresh' ,'no');
}}
$window.onfocus = $scope.focusOnPageCall();
【问题讨论】:
标签: javascript angularjs browser