If you want to open the fileBrowser by an external script, you might run into the problem that you have no real control over the function that is called onclick of a file in the browser. This can be solved by overwriting the specific function with a provided callback function:
Hmmm, no idea why the color coding is -well- not there... I also 'pastied' it, see http://pastie.org/247601
// use the openFileBrowser funtion to open the fileBrowser and provide a function to be triggered onclick of a file in the fileBrowser openFileBrowser(FCKConfig, url, width, height, function(fileBrowser, fileUrl){ // this is the function that will be triggered onclick of a file in the fileBrowser; it will receive a reference to the fileBrowser window and the url of the selected file fileBrowser.close(); // fileBrowser is a reference to the fileBrowser window, so to close it we can just use the close function fileBrowser.opener.focus(); // and fileBrowser.opener points to the window from where we opened the fielManager, so to return focus to that window we use the focus function on the opener alert(encodeURI(fileUrl).replace('#', '%23')); // now we can do anything we want with the returned fileUrl }); // opens the fileBrowser and overwrites the function that gets called when a file is selected in the fileBrowser function openFileBrowser(FCKConfig, url, width, height, callback) { var left = (FCKConfig.ScreenWidth - width) / 2; var top = (FCKConfig.ScreenHeight - height) / 2; // open the fileBrowser var fileBrowser = window.open(url, 'FCKBrowseWindow', 'toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top); // if a callback function is provided if (typeof(callback) == 'function') { // create the poll function var poller = function(){ if (fileBrowser.frmResourcesList && fileBrowser.frmResourcesList.OpenFile) // when the frmResourcesList is loaded with the function OpenFile { // overwrite the OpenFile with the callback function scoped to be able to pass the fileBrowser variable fileBrowser.frmResourcesList.OpenFile = (function (fileBrowser) { return function (fileUrl) { callback(fileBrowser, fileUrl); } })(fileBrowser); } else { // if the fileBrowser wasn't fully loaded yet run the poller function again (with a delay of again 100ms) setTimeout(poller, 100); } } // check the load state of the fileBrowser with the poller function (with a delay of 100ms) setTimeout(poller, 100); } }
Re: Dynamic openFileBrowser function
Re: Dynamic openFileBrowser function
Re: Dynamic openFileBrowser function
Changing the internal function that calls your function is much more risky that changing your function. Avoid at all cost messing with anything marked as internal or private in any project that you use from the outside.
Re: Dynamic openFileBrowser function