# Interesting post on getting Mozilla XUL running inside Internet Explorer by Jean-Yves Cronier

<datetime class="hidden">2005-10-30T00:00</datetime>
<!-- category -- mostlylucidcouk, Imported -->

## 
Interesting post on getting Mozilla XUL running inside Internet Explorer by Jean-Yves Cronier 

posted on Sunday, September 12, 2004 11:46 AM

Let the crossover continue!  Jean-Yves Cronier left [a comment](/archive/2003/11/23/648.aspx) on my [old post about HTC inside Mozilla](/archive/2003/11/23/648.aspx), he points to a post he left in the [XULPlanet forum](http://xulplanet.com/forum/viewtopic.php?t=1038) showing a technique to get [XUL behaviours](http://xulplanet.com/tutorials/whyxul.html) running inside of Internet Explorer using a simple HTC behaviour as a sort of interface layer. This is again, pretty cool - and would be even cooler if it could be extended to allow complete translation between all IE HTC behaviours and their XUL equivalent! Anyway, since this is posted on a forum I know nothing abot, I'll repeat the post here:

I've reflected on possibilities offered by famous behavior HTC under IE. I think it would be perhaps possible to interpret a small part of specifications of XUL. 

A little sample: 

index.xul :

| <!----> |
| --- |
| **Code:** |
| &lt;?xml version="1.0" encoding="iso-8859-1"?&gt; <br>&lt;?xml-stylesheet type="text/css" href="xul.css" media="all"?&gt; <br>&lt;window id="example-window" title="Example" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt; <br>&lt;label control="some-text" value="Enter some text"/&gt; <br>&lt;textbox id="some-text" value="toto"/&gt; <br>&lt;label control="some-password" value="Enter a password"/&gt; <br>&lt;textbox id="some-password" type="password" maxlength="8"/&gt; <br>&lt;menulist label="Bus"&gt; <br>  &lt;menupopup&gt; <br>    &lt;menuitem label="Car"/&gt; <br>    &lt;menuitem label="Taxi"/&gt; <br>    &lt;menuitem label="Bus" selected="true"/&gt; <br>    &lt;menuitem label="Train"/&gt; <br>  &lt;/menupopup&gt; <br>&lt;/menulist&gt; <br>&lt;/window&gt; |

xul.css :

| <!----> |
| --- |
| **Code:** |
| label{behavior:url(label.htc)} <br>menuitem{behavior:url(menuitem.htc)} <br>menulist{behavior:url(menulist.htc)} <br>menupopup{behavior:url(menupopup.htc)} <br>textbox{behavior:url(textbox.htc)} <br>window{behavior:url(window.htc)} |

label.htc :

| <!----> |
| --- |
| **Code:** |
| &lt;public:htc urn="window"&gt; <br>&lt;public:attach event="ondocumentready" handler="build" /&gt; <br>&lt;public:property name="value" /&gt; <br>&lt;script type="text/javascript"&gt; <br>function build(){this.innerHTML=this.value;} <br>&lt;/script&gt; <br>&lt;/public:htc&gt; |

menuitem.htc :

| <!----> |
| --- |
| **Code:** |
| &lt;public:htc urn="window"&gt; <br>&lt;public:attach event="ondocumentready" handler="build" /&gt; <br>&lt;public:property name="id" /&gt; <br>&lt;public:property name="label" /&gt; <br>&lt;public:property name="value" /&gt; <br>&lt;script type="text/javascript"&gt; <br>function build() { <br>   var option = document.createElement("option"); <br>   var style=this.currentStyle; <br>   option.setAttribute("id",id); <br>   if(this.id!=null){option.setAttribute("id",this.id);} <br>   if(this.value!=null){option.setAttribute("value",this.value);} <br>   if(label!=null){option.innerHTML=label;} <br>   for(var prop in style){option.style[prop]=style[prop];} <br>   this.outerHTML=option.outerHTML; <br>} <br>&lt;/script&gt; <br>&lt;/public:htc&gt; |

menulist.htc :

| <!----> |
| --- |
| **Code:** |
| &lt;public:htc urn="window"&gt; <br>&lt;public:attach event="ondocumentready" handler="build" /&gt; <br>&lt;public:property name="id" /&gt; <br>&lt;script type="text/javascript"&gt; <br>function build() { <br>   var select = document.createElement("select"); <br>   var style=this.currentStyle; <br>   select.setAttribute("id",id); <br>   if(id!=null){ <br>      select.setAttribute("id",this.id); <br>      select.setAttribute("name",this.id); <br>   } <br>   select.innerHTML=this.innerHTML; <br>   for(var prop in style){ <br>      select.style[prop]=style[prop]; <br>   } <br>   select.style.width="100%"; <br>   this.outerHTML=select.outerHTML; <br>} <br>&lt;/script&gt; <br>&lt;/public:htc&gt; |

menupopup.htc :

| <!----> |
| --- |
| **Code:** |
| &lt;public:htc urn="window"&gt; <br>&lt;public:attach event="ondocumentready" handler="build" /&gt; <br>&lt;public:property name="id" /&gt; <br>&lt;public:property name="label" /&gt; <br>&lt;public:property name="value" /&gt; <br>&lt;script type="text/javascript"&gt; <br>function build() { <br>   var optgroup = document.createElement("optgroup"); <br>   var style=this.currentStyle; <br>   if(this.id!=null){optgroup.setAttribute("id",this.id);} <br>   if(this.label!=null){optgroup.innerHTML=this.label;} <br>   optgroup.innerHTML=this.innerHTML; <br>   for(var prop in style){optgroup.style[prop]=style[prop];} <br>   this.outerHTML=optgroup.outerHTML; <br>} <br>&lt;/script&gt; <br>&lt;/public:htc&gt; |

textbox.htc :

| <!----> |
| --- |
| **Code:** |
| &lt;public:htc urn="window"&gt; <br>&lt;public:attach event="ondocumentready" handler="build" /&gt; <br>&lt;public:property name="id" /&gt; <br>&lt;public:property name="value" /&gt; <br>&lt;public:property name="type" /&gt; <br>&lt;public:property name="maxlength" /&gt; <br>&lt;script type="text/javascript"&gt; <br>function build() { <br>   var input = document.createElement("input"); <br>   var style=this.currentStyle; <br>   input.setAttribute("id",id); <br>   if(value!=null){input.setAttribute("value",value);} <br>   if(type!=null){input.setAttribute("type",type);} <br>   if(maxlength!=null){input.setAttribute("maxlength",maxlength);} <br>   for(var prop in style){input.style[prop]=style[prop];} <br>   input.style.width="100%"; <br>   input.style.cursor="text"; <br>   input.style.borderStyle="inset"; <br>   input.style.borderColor="ActiveBorder"; <br>   input.style.borderWidth="2px"; <br>   input.style.backgroundColor="#FFFFFF"; <br>   input.style.paddingLeft="2px"; <br>   this.outerHTML=input.outerHTML; <br>} <br>&lt;/script&gt; <br>&lt;/public:htc&gt; |

window.htc :

| <!----> |
| --- |
| **Code:** |
| &lt;public:htc urn="window"&gt; <br>&lt;public:attach event="ondocumentready" handler="build" /&gt; <br>&lt;public:property name="title" /&gt; <br>&lt;script type="text/javascript"&gt; <br>function build(){window.status=this.title;} <br>&lt;/script&gt; <br>&lt;/public:htc&gt; |

It's Funny ! Is'nt it ? ![Very Happy](http://xulplanet.com/forum/images/smiles/icon_biggrin.gif) 

The goal of a project like this on isn't to rise Internet Explorer but just to show a little overview to other ones (who haven't got Mozilla Web Browser) the technologies available with Mozilla Framework