[geeks] javascript tutorial sought?

Jonathan C. Patschke jp at celestrion.net
Tue Aug 12 09:40:58 CDT 2008


On Tue, 12 Aug 2008, der Mouse wrote:

>> First, you can't open arbitrary network connections in the web browser.
>> You can only open http connections to the server that delivered the web
>> page.
>
> Only HTTP, or only port 80?  If the former, how much do they have to
> look like HTTP?

Only HTTP.  You can really only send HTTP requests (GET/PUT/POST/HEAD)
back to the same server the page and/or script originated from.

Generally, the way this is done is you have program on the server (either
a CGI or some J2EE slop) that brokers most of your state data for you, and
the JavaScript client periodically gets/sets state inside that CGI by
means XMLHttpRequest.

> (I really don't want to have to layer TCP atop HTTP, especially since
> it's not clear there's any way for the server to get the client's
> attention asynchronously.)

No, applications have to poll.

> I basically want to turn the web browser into a (very specialized)
> "termnial emulator" designed to support card games rather than text
> "console" applications.  Perhaps JavaScript is a wrong approach?

A Java applet would probably work a lot better for this sort of thing, as
you can use real networking (although, again, only back to the originating
server).  However, that'll leave you constrained either to an ancient API
(1.1) or add an additional requirement of a recent Java runtime.  There's
also the nasty delay your users will see if your applet happens to be the
first one they load that browser-session.

>> If at all possible, I'd stick with using CSS, even if that means
>> pre-rendering a bunch of sprites.
>
> I currently have _no_ handle on CSS.  Perhaps I need to change that.

CSS is the only real way to manipulate what's seen in the browser via
Javascript.  Not CSS the language, but the DOM wrappers around CSS.

I've been writing web applications since 1995 using very nearly every
technology out there.  I have yet to find a single one that makes the web
browser an acceptable platform for application delivery that doesn't toss
out the browser entirely (ie: applets/plugins).  It's pretty
disheartening.

-- 
Jonathan Patschke | "There is more to life than increasing its speed."
Elgin, TX         |                                   --Mahatma Gandhi
USA               |



More information about the geeks mailing list