Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2005-04-25 10:42:07

u101440
New member
Registered: 2005-04-25
Posts: 5

Loading Xinha

I'm trying to load Xinha without needing to alter the body tag (it's says that I can do this in the Newbie Guide) as I don't waant to have to include the initiation code within every page (even those that don't use Xinha). So far I've not been successful in getting this to work. I've got pages working where I call Xinha via the body tag but can anyone point me in the right direction as to why this may not be working.

I can happily supply code should you wish.

Offline

#2 2005-04-25 11:22:58

niko
Xinha Authority
From: Salzburg/Austria
Registered: 2005-02-14
Posts: 338

Re: Loading Xinha

...you want do start xinha WITHOUT a <body onload> and WITHOUT a <script> area?
this won't work...

post the code where you got problems!


Niko

Offline

#3 2005-04-26 02:51:51

u101440
New member
Registered: 2005-04-25
Posts: 5

Re: Loading Xinha

Thanx for looking at this. I simply don't won't to include the onload event in the body of the page. I'm aware that I'll need the <script> content within the page. Here is the basis of my page (removed the unimportant elements):

    <script type="text/javascript">
      _editor_url = "/xinha2/";
      _editor_lang = "en";
    </script>

    <!-- load the main HTMLArea files -->
    <script type="text/javascript" src="/xinha2/htmlarea.js"></script>
    <script type="text/javascript" src="/xinha2/my_config.js"></script>

    <script type="text/javascript">
      HTMLArea.loadPlugin("FullPage");

      function initDocument() {
        var editor = new HTMLArea("editor");
        editor.registerPlugin(FullPage);
        editor.generate();
      }

      HTMLArea.onload = initDocument;
    </script>

I have a textarea called editor on the page.

The my_config.asp file looks like this:

    xinha_editors = null;
    xinha_init    = null;
    xinha_config  = null;
    xinha_plugins = null;

    // This contains the names of textareas we will make into Xinha editors
    xinha_init = xinha_init ? xinha_init : function()
    {
      /** STEP 1 ***************************************************************
       * First, what are the plugins you will be using in the editors on this
       * page.  List all the plugins you will need, even if not all the editors
       * will use all the plugins.
       ************************************************************************/

      xinha_plugins = xinha_plugins ? xinha_plugins :
      [
       'CharacterMap',
       'ContextMenu',
       'FullScreen',
       'ListType',
       'SpellChecker',
       'Stylist',
       'SuperClean',
       'TableOperations'
      ];
             // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  smile
             if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;

      /** STEP 2 ***************************************************************
       * Now, what are the names of the textareas you will be turning into
       * editors?
       ************************************************************************/

      xinha_editors = xinha_editors ? xinha_editors :
      [
        'myTextArea',
        'anotherOne',
        'newbiearea1',
        'ta',
        'editor'
      ];

      /** STEP 3 ***************************************************************
       * We create a default configuration to be used by all the editors.
       * If you wish to configure some of the editors differently this will be
       * done in step 4.
       *
       * If you want to modify the default config you might do something like this.
       *
       *   xinha_config = new HTMLArea.Config();
       *   xinha_config.width  = 640;
       *   xinha_config.height = 420;
       *
       *************************************************************************/

       xinha_config = xinha_config ? xinha_config : new HTMLArea.Config();

      /** STEP 3 ***************************************************************
       * We first create editors for the textareas.
       *
       * You can do this in two ways, either
       *
       *   xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
       *
       * if you want all the editor objects to use the same set of plugins, OR;
       *
       *   xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config);
       *   xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']);
       *   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
       *
       * if you want to use a different set of plugins for one or more of the
       * editors.
       ************************************************************************/

      xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);

      /** STEP 4 ***************************************************************
       * If you want to change the configuration variables of any of the
       * editors,  this is the place to do that, for example you might want to
       * change the width and height of one of the editors, like this...
       *
       *   xinha_editors.myTextArea.config.width  = 640;
       *   xinha_editors.myTextArea.config.height = 480;
       *
       ************************************************************************/


      /** STEP 5 ***************************************************************
       * Finally we "start" the editors, this turns the textareas into
       * Xinha editors.
       ************************************************************************/

      HTMLArea.startEditors(xinha_editors);
    }

    window.onload = xinha_init;

Now if I don't alter the body tag of the above file then nothing is shown in the textarea except and emtpy shell. If I change the body tag to:

<body onload="HTMLArea.init()">

Then the page loads exactly as it should.

I read somewhere that window.onload was meant to take care of this so no need to load the function via the onload event in the body.

I'm using IE6 and don't need it for any other browser.

Offline

#4 2005-04-26 06:03:41

u101440
New member
Registered: 2005-04-25
Posts: 5

Re: Loading Xinha

Figured it out. Believe it or not I was pressing F5 when the page wasn't loading properly and this wasn't working. Pressing Go beside the address bar made the editor work...go figure.

Thanx again for all your help.

Offline

#5 2005-04-26 07:42:34

akaEdge
Xinha Community Member
From: London
Registered: 2005-03-05
Posts: 16

Re: Loading Xinha

I think you will find that sometimes the area loads and sometimes is doesn't. I was finding clicking "refresh" was working fine but clicking on a link within another page was not (maybe something to do with caching and page loading orders?)

I did the exact same thing and found that the Xinha Area will load most of the time just using the window.onload line. However it won't work if you put anything else at all in the <body onload="">

So <body onload="alert('hi')"> will make the editor not load. If you want it to load in this scenario you need to put something like this <body onload="alert('hi'); xinha_init();">


akaEdge

Offline

#6 2005-04-26 10:29:35

mokhet
Xinha Authority
From: Paris, France
Registered: 2005-04-03
Posts: 105
Website

Re: Loading Xinha

If you dont want or cant alter the onload, something like the following should do the trick correctly.

<body onload="alert('hi');">
...
...
<script type="text/javascript">
var oldOnLoad = window.onload;
window.onload = function(e) {
if (oldOnLoad) oldOnLoad(e);
xinha_init();
}
</script>

Offline

Board footer

Powered by FluxBB