XML
  Home arrow XML arrow Page 4 - An Introduction to XUL Part 3
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
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? 
Google.com  
XML

An Introduction to XUL Part 3
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2005-06-06


    Table of Contents:
  • An Introduction to XUL Part 3
  • Flex and Grids
  • Groupbox, Stack and Deck
  • Content Elements

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    An Introduction to XUL Part 3 - Content Elements
    ( Page 4 of 4 )

    All I’ve talked about so far are elements; interface elements and layout elements.  What I haven’t mentioned yet are content elements.  We’ve seen buttons, labels, controls etc, but nothing in which to actually store content.  What that content actually is depends on what the application does, for a browser, such as Mozilla, the main content is HTML pages.  As XUL came around in order for Mozilla to actually be constructed, HTML pages are easily displayed using an iframe element.  To test this out fully, you’ll need a web page to display.  You could create one of your own, or to save yourself some time you could work with something that’s already out there.

    What I did was to go to the Google homepage (because it has a relatively simple homepage but features many links and has some functionality) in a browser, and save the page as google.htm to my XUL directory.  Do whatever you want, but get an HTML file that at least has links to other pages on it.  Now, create a basic window (I mean add the opening and closing window element to a blank text file with the necessary namespace) with nothing in it except the following line of code:

    <iframe src="google.htm" flex="1"/>     

    Note that the attribute must be included, or the page will not open within the iframe.  Now, save it as iframe.xul or similar and then execute it with the command line.  Your window should appear with the Google homepage loaded in it.  The links should work and you can even do actual searches with it.  You’ve just created a browser, with just a couple of lines of code!  If your window is smaller than the size of the page you’ve selected for this example, Mozilla will even include working scrollbars for you, with no additional code.  You’re not restricted to displaying just web pages either, change the src attribute of the iframe to one of the XUL files you’ve already created and watch in awe as that is loaded just as easily.  It will even render simple text files, which you can prove by changing the src to a file ending in .txt.  The files that you’re opening should be located in the same directory as the iframe.xul file, or should include the full path to them if they’re not.

    I feel it appropriate to mention at this point that true to its XML roots, XUL is also able to work with and process HTML tags and render them within its windows accordingly.  In order to use the tags that it supports you need to make sure that the XHTML namespace is imported.  This requires the addition of the namespace to the opening window tag, and an HTML prefix preceding each HTML element you wish to use.  Create the following file for confirmation of this:

    <?xml version="1.0"?>
    <window
      id="html"
      title="Render HTML"
      width="500"
      height="300"
      screenX="50"
      screenY="100"
      xmlns="http://www.mozilla.org/keymaster/gatekeeper/
      there.is.only.xul"
      xmlns:html="http://www.w3.org/1999/xhtml"> 

    <html:div>
      This is HTML!
    </html:div>
    <html:ol>
      <html:li>This is an html list item!</html:li>
      <html:li>So is this!</html:li>
    </html:ol>

    </window>

    So you see, there are several very basic ways to include content within your XUL files.  The next article introduces RDF, and explains how more complex elements can be access via a chrome URL from within Mozilla to give added functionality and power to your XUL applications.



     
     
    >>> More XML Articles          >>> More By Dan Wellman
     

       

    XML ARTICLES

    - Flex Array Collection Sort and Filtering
    - The Flex Tree Control
    - Flex List Controls
    - Working with Flex and Datagrids
    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek