used to the noose they obey
Jul 18, 2008 17:08 EDT
You know what I want to see in a next-generation browser? The ability to create custom elements. I want to be able to write my own tag in xhtml and have the browser automatically load code, probably javascript, that would create and return that object to the browser so it could place it in the appropriate place in the dom.
It would be so easy to implement too. First you specify a path in the xhtml, say by doing the following
<link rel="elementpath"
type="text/javascript"
href="/elementjs/" />
Then anytime the browser found an element it didn't know of, it would try to load it via the path, for example.
Broswer finds element <combobox>
Browser tries to load /elementjs/combobox.js
Inside combobox.js there might be a function like,
function htmlCombobox(attributes, xml, text) {
// Create input box
el = document.createElement('input');
// Create div
el.dropdown = document.createElement('div');
for(i=0;i<xml.length;++i) {
// Create lines in the div
// That would act like <option>
// tags. Then attach them to the
// dropdown
}
// Attach callbacks to the element
el.onclick = htmlComboboxClick;
// Return the element so the browser
// can place it in the dom.
return el;
}
function htmlComboboxClick(event) {
// Do something on click, etc.
}
The arguments xml and text would work much like XMLHttpRequest's responseXML and responseText, allowing the code to create the child elements as well. Though for ease of use an additional core JavaScript function would be needed, one you could pass those child elements you don't want to create, or maybe not, I'd have to think about that.
Still, how f-ing cool would that be?
The Mars Volta - Miranda That Ghost Just Isn't Holy Anymore: A. Vade Mecum
ok
SwearFu