解决方案是使用“pageshow”事件。这是完整的 HAML 解决方案
.modal.fade
.modal-header
%h1 Sync XXX to your iPhone
.modal-body
%p Some explanation
.modal-footer
= link_to "OK", apple_sync_profile_user_url, class: 'btn btn-primary add-profile'
- content_for :bottom do
:javascript
var clicked = false;
$('.add-profile').click(function() {
clicked = true;
});
var redirect = function () {
if(clicked)
window.location = 'CerProv/deviceprofile.mobileprovision';
};
window.addEventListener('pageshow', redirect, false);
$('.modal').modal({backdrop: 'static', keyboard: true})
编辑
对 Dimpal 代码的改编:
//on the click of a button
$('#popup .enroll').click(function(){
$('#popup').hide('100');
$('#wrapper1').css('opacity','1');
$('#wrapper1 a').attr('onclick','return true');
// after hitting the following url the browser window disappears and profile installation window of ios device will open....
window.open("CerProv/taxiopen-1.mobileprovision");
//now whenever the profile installation on ios device will be completed i want the current browser window to be opened automatically and start execution from the just next line automatically i.e. it should redirect on this url
window.addEventListener('pageshow', function() {window.open("getstarted.html");});
});