PDA

View Full Version : HtmlEditor IE8 Scripted Windows Warning



benshort
20 Oct 2009, 4:17 AM
Hi,

I'm using the HtmlEditor but have run into an issue when using IE8 and IE7 ( IE8 in compatibility mode).

When I click on the HyperLink button IE displays the following message in its Information Bar.

This website is using a scripted window to ask you for information. If you trust this website, click here to allow scripted windows...

Sadly the guys in my support department tell me that the customers will find this unacceptable.

So I have tried to override createLink method and made it show an Ext MessageBox prompt which resolve the scripted windows error as shown below.



Ext.onReady(function() {

Ext.QuickTips.init();

var editor = new Ext.form.HtmlEditor({
id: 'details',
name: 'details',
renderTo: 'detailsEditor',
enableSourceEdit: false,
width: 483,
defaultFont: 'Arial',
defaultValue: '${form.details}',
createLink: function() {
Ext.MessageBox.show({
title : 'HyperLink',
msg : this.createLinkText,
buttons: Ext.MessageBox.OKCANCEL,
minWidth:250,
scope : null,
prompt:true,
multiline: false,
value: this.defaultLinkValue,
fn: function(btn, url) {
if ( btn == 'ok' ) {
if(url && url != 'http:/'+'/'){
editor.relayCmd('createlink', url);
}
}
}
});
}
});

})


The code works fine in FF and Chrome but in IE6, IE7 or IE8 (with or without compatibility view enabled) the highlighted text doesn't get converted to a http link.

Any ideas how I might resolve this?

Regards

Ben Short

benshort
20 Oct 2009, 4:47 AM
I just noticed that in IE the text I selected before clicking the HyperLink button is deselected when the EXt MessageBox is displayed. This does not happen in chrome or ff.

benshort
20 Oct 2009, 6:53 AM
Fixed. Tested in IE6, IE7, IE8(+Compat), FF 3.5.3 and Chrome 3.0.195.27



Ext.onReady(function() {

Ext.QuickTips.init();

var editor = new Ext.form.HtmlEditor({
id: 'details',
name: 'details',
renderTo: 'detailsEditor',
enableSourceEdit: false,
width: 483,
defaultFont: 'Arial',
defaultValue: '${form.details}',
createLink: function() {

var range = null;

if ( Ext.isIE ) {
var win = this.iframe.contentWindow;
var doc = win.document;
var selection = doc.selection;
range = selection.createRange();
}

Ext.MessageBox.show({
title : 'HyperLink',
msg : this.createLinkText,
buttons: Ext.MessageBox.OKCANCEL,
minWidth:250,
scope : this,
prompt:true,
multiline: false,
value: this.defaultLinkValue,
fn: function(btn, url) {
if ( range != null ) {
range.select();
}
if ( btn == 'ok' ) {
if(url && url != 'http:/'+'/'){
editor.relayCmd('createlink', url);
}
}
}
});
}
});
})