Posts Tagged ‘javascript’

Stupid IE (2)

Sunday, September 2nd, 2007

To create a multiple select-box with javascript you need a very ugly hack in IE.

if (navigator.appName.match(/Internet Explorer/)) {
	fsel = document.createElement(\'<SELECT MULTIPLE>\');
} else {
	fsel = document.createElement(\'select\');
	fsel.multiple = true;
}

Stupid IE (1)

Sunday, September 2nd, 2007
if(!Array.prototype.indexOf) {
	Array.prototype.indexOf = function(el) {
		var i = 0;
		for(; i < this.length; i++)
			if(this[i] == el)
				return i;
		return -1;
	};
}

Easy Crossbrowser JavaScript

Wednesday, March 16th, 2005

The major problem when dealing with javascript for me was that javascript acts differently on each different browser. And there are a lot of browsers supporting javascript.
Usualy to get it working it would include having for each sensitive operation a big if block. And in the a bit nicer javascripts that would become a lot. Also it becomes hard to maintain.

So what to do about it?

Actually.. C(++) gave me a possible solution. Use macro`s. It ain’t possible to use macro`s in javascript itself feasable, so what you do is you compile your javascript with macro`s to a different javascript file for each browser. Then using a simple server side script you can let the browser get what it wants.

I’m not a javascript guru, so I hardly know all the problems of each browser.

If a javascript guru does read it, please contact me - it would be great to have such a goodie.

Rich Client Side Framework

Tuesday, December 14th, 2004

On several blogs the idea of having a rich java script passed, for example on ZefHemel.com: Rich Web UI: Search As You Type

Guess due to google, which has made a neat Webmail interface for gmail and Google suggest with find as you type.

The demands on java script keeps growing. People want to make better webUI’s and features with Javascript although javascript is defenitely not designed for this stuff.

Using flash, and java is an overkill, but using javascript is espacially an overkill for javascript isnt handled consistantly on different browsers, and isn’t as quick and maintainable as it could be.

I guess it would be time to extend HTML itself with a more advanced script; java like preferably although then directly supported by the browser, and less aimed at custom drawing but using an API provided by the browser.

I’m currently experimenting with Microsoft .net assemblies which are downloaded in slimmed form as webpage which are executed with very limited access. Which works neat although it is still an overkill (a .dll is about 20 Kb, even if you got only one line of code..)

Just a thought.