0
我讀到,如果用戶單擊鏈接,則可以使用JavaScript打開它,並且它不會被彈出窗口阻止程序阻止。你可以看到,在這裏:用戶動作的鏈接被當作彈出窗口並被阻止
Allow window.open to open new window and not popup
所以,棱角分明,我創造了這個指令:
.directive('kdExport', function() {
return {
restrict: 'A',
scope: {
options: '=kdExport'
},
controller: 'ExportImageController',
link: function (scope, element, attrs, controller) {
// Bind to the onclick event of our button
element.bind('click', function (e) {
// Prevent the default action
e.preventDefault();
// Copy our options
angular.extend(controller.options, scope.options);
// Generate the image
controller.generateImage(function (preview) {
// Create our url
var url = '/kits/preview/' + preview.id;
// Open a new window
window.open(url, '_blank');
});
});
}
};
})
的問題是,它被封鎖在IE中。 如何防止IE阻止此鏈接?
好吧,我的代碼執行完成後(generateImage有承諾),我怎麼能打開窗口。 – r3plica
@ r3plica你不能在承諾中做到這一點,因爲它不僅僅是在用戶操作之後 –