[Seaside] Can Seaside detect if a browser has Javascript support disabled?

Lukas Renggli renggli at gmail.com
Fri Mar 23 18:57:44 UTC 2007


> I was reading a few news items on the smalltalk newsgroup
> (comp.lang.smalltalk) and there is a thread about Squeak/Ajax and it got
> me wondering if someone tried using my Ajax enabled Seaside app with a
> JS-less browser, is Seaside would be capable of detecting that condition
> and notifying them that JS needs to be enabled for the site to function
> properly?  I'm sure I'll get comments suggesting that I make sure the
> site degrades gracefully if JS is disabled (which I already know!) -- I
> just want to know if Seaside can detect that condition or not...

This has not much to do with Seaside. With Seaside you can access all
the information available trough request headers, etc.

To detect if JavaScript is enabled you need a trick (ask Google, I am
sure there are a lot of possible solutions). Something like
redirecting to a different page using JavaScript could help you gather
this information.

What I rather suggest is to write code that gracefully degrades if no
JavaScript is available. It is very strait forward to do this with
Scriptaculous:

html span
	id: 'counter';
	with: count.
html space.
html anchor
	onClick: (html updater
		id: 'counter;
		callback: [ :render | self decrease. r render: count ];
		return: false);
	callback: [ self decrease ];
	with: '--'.
html space.
html anchor
	onClick: (html updater
		id: 'counter;
		callback: [ :r | self increase. r render: count ];
		return: false);
	callback: [ self increase ];
	with: '++'

Note: the 'return: false' is important to make sure that the event
handling is stopped to avoid a full page reload.

Cheers,
Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch


More information about the seaside mailing list