Fix javascript errors in IE on page with iframe that points to another domain

pull/5754/head
Aleksander Machniak 8 years ago
parent 9fe1cf16b3
commit 8ed954838b

@ -28,6 +28,7 @@ CHANGELOG Roundcube Webmail
- Fix handling of 'mailto' and 'error' arguments in message_before_send hook (#5347)
- Fix missing localization of HTML editor when assets_dir != INSTALL_PATH
- Fix handling of blockquote tags with mixed case on html2text conversion (#5363)
- Fix javascript errors in IE on page with iframe that points to another domain
RELEASE 1.2.0
-------------

@ -612,16 +612,12 @@ function rcube_webmail()
}
// catch document (and iframe) mouse clicks
var body_mouseup = function(e){ return ref.doc_mouse_up(e); };
var body_mouseup = function(e) { return ref.doc_mouse_up(e); };
$(document.body)
.mouseup(body_mouseup)
.keydown(function(e){ return ref.doc_keypress(e); });
.keydown(function(e) { return ref.doc_keypress(e); });
$('iframe').on('load', function(e) {
try { $(this.contentDocument || this.contentWindow).on('mouseup', body_mouseup); }
catch (e) {/* catch possible "Permission denied" error in IE */ }
})
.contents().on('mouseup', body_mouseup);
rcube_webmail.set_iframe_events({mouseup: body_mouseup});
// trigger init event hook
this.triggerEvent('init', { task:this.task, action:this.env.action });
@ -8981,6 +8977,23 @@ rcube_webmail.subject_text = function(elem)
return t.text();
};
// set event handlers on all iframe elements (and their contents)
rcube_webmail.set_iframe_events = function(events)
{
$('iframe').each(function() {
var frame = $(this);
$.each(events, function(event_name, event_handler) {
frame.on('load', function(e) {
try { $(this).contents().on(event_name, event_handler); }
catch (e) {/* catch possible permission error in IE */ }
});
try { frame.contents().on(event_name, event_handler); }
catch (e) {/* catch possible permission error in IE */ }
});
});
};
rcube_webmail.prototype.get_cookie = getCookie;
// copy event engine prototype

@ -827,20 +827,6 @@ function rcmail_scroller(list, top, bottom)
};
};
// Events handling in iframes (eg. preview pane)
function iframe_events()
{
// this==iframe
try {
var doc = this.contentDocument ? this.contentDocument : this.contentWindow ? this.contentWindow.document : null;
$(doc).mouseup(function(e) { rcmail_ui.body_mouseup(e); });
}
catch (e) {
// catch possible "Permission denied" error in IE
};
};
// Abbreviate mailbox names to fit width of the container
function rcube_render_mailboxlist()
{
@ -1015,8 +1001,7 @@ function rcube_init_mail_ui()
update_quota(rcmail.env.quota_content);
rcmail.addEventListener('setquota', update_quota);
$('iframe').on('load', iframe_events)
.contents().mouseup(function(e) { rcmail_ui.body_mouseup(e); });
rcube_webmail.set_iframe_events({mouseup: function(e) { return rcmail_ui.body_mouseup(e); }});
if (rcmail.env.task == 'mail') {
rcmail.addEventListener('enable-command', 'enable_command', rcmail_ui)

Loading…
Cancel
Save