Opened 13 years ago

Last modified 11 years ago

#8288 confirmed Bug

Internet Explorer will not run blank javascript function as per documentation

Reported by: Keven Owned by:
Priority: Normal Milestone:
Component: General Version: 3.1.1
Keywords: IE HasPatch Cc:

Description

As per: http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_%28Uploader%29/Custom_File_Browser#Example_4

Example 4 works fine in all browsers I have tested except IE. Both IE 8 and 9 will not run the additional javascript called, returning only the URL of the image.

Attachments (1)

CKeditor_javascriptie.JPG (125.9 KB) - added by Keven 13 years ago.
Same page on IE (left) and Chrome (right) the browse server calls the same page which returns different results on IE than other browsers.

Download all attachments as: .zip

Change History (10)

Changed 13 years ago by Keven

Attachment: CKeditor_javascriptie.JPG added

Same page on IE (left) and Chrome (right) the browse server calls the same page which returns different results on IE than other browsers.

comment:1 Changed 13 years ago by Keven

Code on custom BROWSE SERVER as follows:

<script>
window.opener.CKEDITOR.tools.callFunction( <%=CKEditorFuncNum%>,'http://bcalpine.com/news/ads/P2P2009.gif', function() {
  // Get the reference to a dialog window.
  var element, dialog = this.getDialog();
  // Check if this is the Image dialog window.
  if (dialog.getName() == 'image') {
    // Get the reference to a text field that holds the "alt" attribute.
    element = dialog.getContentElement( 'info', 'txtAlt' );
    // Assign the new value.
    if ( element )
      element.setValue( 'this value' );
	  
    element = dialog.getContentElement( 'info', 'txtBorder' );
    // Assign the new value.
    if ( element )
      element.setValue( '2' );
	  
    element = dialog.getContentElement( 'info', 'txtHSpace' );
    // Assign the new value.
    if ( element )
      element.setValue( '3' );
	  
    element = dialog.getContentElement( 'info', 'txtVSpace' );
    // Assign the new value.
    if ( element )
      element.setValue( '4' );

    element = dialog.getContentElement( 'Link', 'txtUrl' );
    // Assign the new value.
    if ( element )
      element.setValue( 'http://bcalpine.com/news/' );
  }
  // Return false to stop further execution - in such case CKEditor will ignore the second argument (fileUrl)
  // and the onSelect function assigned to a button that called the file browser (if defined).
//  return false;
});
window.close();
</script>
Last edited 13 years ago by Jakub Ś (previous) (diff)

comment:2 Changed 13 years ago by Keven

Additional testing included replacing the entire blank function with function() {alert('TEST')} which fired on all browsers EXCEPT internet explorer on any version.

comment:3 Changed 13 years ago by Wiktor Walc

Keywords: filebrowserImageBrowseUrl removed
Status: newconfirmed

Confirmed. In IE, when passing a function as an argument from a popup window, typeof returns object instead of a function in the following line: line 375

A different method of checking whether variable is a function is needed here.

comment:4 Changed 13 years ago by Wiktor Walc

Version: 3.6.13.1.1

comment:5 in reply to:  4 Changed 12 years ago by z.kwiecinski

Hi. When run ckeditor from source code, its work fine (tested in IE6). In ie6 function typeof is non-deterministic.

I replace problematic condition with test exist function call: if (data.call && ...

Its work in IE6 and Fireofx 3.6, other browser hasn't tested.

comment:6 Changed 12 years ago by Anna Tomanek

This is also discussed on the community forum: http://cksource.com/forums/viewtopic.php?f=11&t=23539

comment:7 Changed 12 years ago by katyp

I am attempting to fix this locally for myself as I was the person bothering the community forum. I am not getting any different results with z.kwiecinski's check in IE9. Sorry if this is the wrong place to contribute.

comment:8 Changed 11 years ago by melker

In Explorer the type seems to be changed from function to object during cross-page call to callFunction.

The local method gives "function" and the remote methods ckeditors code gives "object".

The following is tested using todays trunk.

In my own filebrowser code:

function testTypeOf(x) {
	alert ("local typeOf: " + typeof x);
	alert ("local typeOf arg: " + typeof arguments[0]);
}

...
var f = function() { 
  alert("Inside function"); 
}
testTypeOf(f);
window.opener.CKEDITOR.tools.testTypeOf(f);
window.opener.CKEDITOR.tools.callFunction( ckEditFuncNum, url, f);

modified code in core/tools.js

...
	testTypeOf : function ( x ) {
		alert ("remote typeOf: " + typeof x);
		alert ("remote typeOf arg: " + typeof arguments[0]);
	},

	callFunction : function( ref ) {
		if (ref == 2) alert("IN callFunction:" + ref + " arg0=" + arguments[0] + " arg1=" + arguments[1] + " arg2=" + arguments[2] + " Targ0=" + typeof arguments[0] + " Targ1=" + typeof arguments[1] + " Targ2=" + typeof arguments[2]);

		var fn = functions[ ref ];
		return fn && fn.apply( window, Array.prototype.slice.call( arguments, 1 ) );
	},
...

Seems like other have the same problem: http://stackoverflow.com/questions/10499623/cant-pass-a-function-from-one-window-to-another-in-ie?rq=1

Their solution is to check:

if ( data && data.call ...

instead of

if ( typeof data == 'function' ...
Last edited 11 years ago by melker (previous) (diff)

comment:9 Changed 11 years ago by Anna Tomanek

Keywords: HasPatch added
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy