htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0 - Add-Ons:
Luis please give me an idea!. OPEN FILE ON LOAD


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


markulius99
Novice

Mar 11, 2004, 2:10 PM

Post #1 of 3 (3225 views)
Shortcut
Luis please give me an idea!. OPEN FILE ON LOAD Can't Post

SmileHi Luis:

Congratulations, your program is great!

I need to open a specif file as soon as HTMLAREA loads. Let's say HTMLAREA opens and it automatically loads c:\xxx.txt. How can I do that?

As I had to idea how to do it, at least I tried calling your openfile dialog. For me it would be just fine to call this dialog window with a filename and path already loaded by default so the user only has to click the 'open' button

I tried this by calling the editor_action function directly from the initial page:
editor_generate('Body');
WriteMenuItems('Body');
editor_action('_Body_OpenFile'); <=== this is what I added

In your program you include the following code in the Openfile section from the editor_action function:

var myText = showModalDialog(_editor_url + "popups/openpage.html",editdoc,"resizable: yes; help: no; status: no; scroll: no; ");

However when I use it nothing happens. If I erase 'editdoc' from the above line, it loads the showModalDialog with a lost formatting but anyway, the data will load but disappear.

=> editdoc in the object that you declared in the middle of the function
var editdoc = editor_obj.contentWindow.document;
These are your declarations related to editdoc:
var objname = button_id.replace(/^_(.*)_[^_]*$/, '$1');
var editor_obj = document.all["_" +objname + "_editor"];


I believe I have a problem with the actual content window when calling the editor_action function from outside
Is the document.all[xxxx] statement the problem because I'm in another area when I call the function?

Please give me an suggestion or another approach about opening a file when loading.

MARKCrazy


Luis
Veteran

Mar 11, 2004, 11:02 PM

Post #2 of 3 (3219 views)
Shortcut
Re: [markulius99] Luis please give me an idea!. OPEN FILE ON LOAD [In reply to] Can't Post

Hi markulius99:

It's pretty easy. The user doesn't even need to click the open button. Everything can be done automatically.

First, your approach on editor_action('_Body_OpenFile'); is correct. You are only missing to delay the ejecution of the function until the editor is fully loaded. Make it:

setTimeout(function(){ editor_action('_Body_OpenFile');}, 1000);

You might need to increase or decrease the delaying time, according to your servers' and user's computer speed and connection. I think 1 second is good enough.

Second, modify openpage.html, using a hidden field instead of a file box.

<INPUT TYPE="hidden" NAME="filepath" SIZE="30" VALUE="C:\\yourdir\\yourfile.html"><BR>

Notice the slash(es) must be escaped(\\) in the file path.

Third, take out both buttons (Open and Cancel), assigning the OpenFile function to the onload event in the body of openpage.html:

<body style="background: threedface; color: windowtext;" margin: 30px; onload="OpenFile(myform.filepath.value, ['','inc', 'htm', 'txt', 'html']);" >

and that's all. It works beautiful. i just tested it.

I hope this be of help.


Don't give up!!
http://webstationone.com/test/htmlarea


(This post was edited by Luis on Mar 12, 2004, 1:31 AM)


markulius99
Novice

Mar 15, 2004, 10:15 AM

Post #3 of 3 (3186 views)
Shortcut
Re: [Luis] Luis please give me an idea!. OPEN FILE ON LOAD [In reply to] Can't Post

Luis quoted "I hope this be of help. "

YES, IT IS. Luis you are owesome, not only for the great solution itself but for taking time to read my post, figure out a solution and send the response. THANK YOU...THANK YOU.

Markulius

 
 
 


Search for (options)