XML
  Home arrow XML arrow Back to XUL: JavaScript Logic
IBM developerWorks
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Back to XUL: JavaScript Logic
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2006-02-06

    Table of Contents:
  • Back to XUL: JavaScript Logic
  • Scripting the Menubar: Close, Exit and New
  • Scripting the Menubar: Open
  • Scripting the Menubar: Save

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Back to XUL: JavaScript Logic


    (Page 1 of 4 )

    Welcome to the fourth article in our "Back to XUL" series. In this article, you will learn how to take the application you have been building and add program logic. By the time you finish reading, you will have a way to open files, display and modify their content, and save files.

    So far, we have written the main interface XUL file, the accompanying DTD containing our English text strings, and registered them in the chrome registry through the use of descriptive RDF files.  You may also have created your own icons or you may have used the ones I provided.  For reference, your application should look a little like this:

     

    Now it is time to bring the application to life with the program logic.  You are going to create a JavaScript file called interface.js, which will reside in the main content folder along with the main interface file.  To link the XUL and JS files, you just use the web-standard script element, which should follow the opening window element:

    <script type="application/x-javascript" src="interface.js"/>

    Our first task is to make the main editor window editable.  This can be done on the onload event handler of the main window, making the application open in a "ready" state.  At the top of a blank file, in your text editor of choice, enter the following function:

    function makeEditable() {
          var editor = document.getElementById('mainContent');
          editor.makeEditable('html',false);
    }

    Then in the opening window element of the interface.xul file, add this event handler:

    onload="makeEditable()"

    This is not a JavaScript tutorial so I won’t explain everything in minute detail, however, I will give a brief explanation of everything.  In the above function, we get the element that we want to affect, in this case the main editor window, and then call the makeEditable method on it.  The HTML parameter is set to false, as not doing this will cause your editor to not be an editor, basically.

    More XML Articles
    More By Dan Wellman


       · Hi everyone,This article is where things start to get interesting because it...
     

    XML ARTICLES

    - Path, Predicates, and XQuery
    - Using Predicates with XQuery
    - Navigating Input Documents Using Paths
    - XML Basics
    - Introduction to XPath
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands
    - Creating an XUL App Installer
    - Overlays in XUL
    - Skinning Your Custom XUL Applications







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway