Welcome to my site here on the world wide web. My name is Svend Tofte, and I'm a student at the University of Copenhagen, where I'm attending the department of Computer Sciences. Scroll on down, for a full list of various stuff I've posted to the site. These are mostly computer related, ranging from web related JavaScript and CSS to university papers (some old ones at any rate).
You might (if your browser is new enough) notice links with little
Gray arrows besides them, these arrows means, that you'll now leave
this site, for another one.
21/3/2007 - The tagline for my site, "featuring almost all new content!" is becoming increasingly embarrasing.
29/5/2006 - Daniel Berlin has reworked my date script and added some functionality. It prompted me to tune the code a little and nice it up some. Thanks Daniel for the improvements!
14/3/2005 - First update in six months! The site is still around, I'm just quite busy with school and work. However, tonight, I was sitting, and solving an annoying JS scoping problem, and figured (in my great arrogance) that other newbies may learn something from this example. It's written very quickly up, but it shows how to solve a very practical problem, using functional programming and closures, and all that good stuff! Since it's not in itself, I figured I'd start a page, where I'd collect snippets/short writeups like this one. Practical (& functional) JavaScript snippets. Comments are always wanted!
19/9/2004 - Raúl González Duque has been so generous, and translated my guide Venkman guide, into spanish! Hopefully this will help spanish users who may find the (technical) english difficult. Go read! (if you know spanish)
11/8/2004 - My summer project is finally coming together, as a solid program. Check out Oop!, a widget program for Windows desktops. Something for both developers and users.
These are various topics I've written on, what I think is, advanced usage of JavaScript. Most of these pages require a fair bit of knowledge of JavaScript as they are pretty heavy on theory. You have been warned. But you might also learn something :)
Learning the JavaScript debugger Venkman
Venkman is a powerful JavaScript debugger, available through the Mozilla browser. It works like most other debuggers, and allows one to get really into ones code, to nail hard to find bugs, or just test certain conditions. It has been written to the JavaScript programmer who isn't familiar with other such tools, so it should be easy for most people to follow. A spanish versions is available here, courtesy of Raúl González Duque.
Curried is a useful technique from the functional languages camp. It's usually not something JavaScript does. I will here explain what curried means, both with examples from ML, and with the theory behind (anonymous/lambda functions). Then, I'll show you can make a one-function-fits-all solution for JavaScript. And I'll then show how to retrofit a function (in this case, the Horspool substring search algorithm), so that it will do precompilation (save processing time).
These are pieces of code, I've written, and I hope are usefull. These are mostly focused on actually doing something, as opposed to the Advanced section above, which is mostly about theory, this section is mostly for finished scripts.
Practical (& functional) JavaScript snippets
This section will contain various snippets and demonstrations of more esoteric areas/uses of JavaScript, that however will solve very practical and real problems. For now it talks about how to repeatedly bind a variable in a loop to different values.
I've always found JavaScript to be lacking a proper and easy way to format dates. And I've always liked PHP's date function for letting you easily format a date. So here's a function, which almost supports all of the same switches PHP's function does. Also includes a guide on how to localize the script, so instead of english, whatever language you want, appears instead. Also, various methods are given, so you can easily verify that the script works in whichever browser you need it to work in, in case your browser isn't listed in the supports table.
Useful prototype methods for JavaScript
Prototyping methods is one of the most useful practical things you can do in JavaScript. Here, I won't show how it's done (that can be learned from many other pages), I will instead list some of the methods I've used, and how they work, and why they're handy.
Cascading style sheets is the language, with which you can give your web pages a look. It's a very expressive language, allowing virtually endless combinations of colorizing your page. Thus there is bound to be pitfalls.
Opera has the great slogan, "Open the web", but this articles delves into just what it means for Opera, to open the web. It details how Opera went from displaying CSS correctly, to displaying it incorrectly, in an effort to emulate the market leader, Internet Explorer.
max-width in Internet Explorer
Internet Explorer per default doesn't support the rather useful
property max-width. I'll show how it's a crucial property
to enable readability on-line, and then how to emulate it, and
in turn many other properties in IE, without much fussing around.
Positioning bug in Classic themed Internet Explorer 6
The headline says it all. If you use absolute positioning, relative to the right side browser edge, you will run into some problems with a classic themed Windows XP running Internet Explorer.
This is a big listing of some of the various Meta tags, you can use with HTML, plus a listing of various Link tags, and finally, a ready to copy-&-paste list of DTDs. Further, there's a short discussion about the structuring of the DTD tag.
You can find most of my really old site content here. I'll warn you, that most of this, isn't totally up to date, if it isn't totally wrong. So now you have been warned.
How to open windows using JavaScript. It includes, besides the obvious example, a reference of all the various parameters I know you can pass to the opening window. I use this mostly for reference.
Making Internet Explorer behave
This is a page, which quickly outlines how to construct behaviors for IE. It gives an example using links in a table, and how the table cells then become clickable.
Locating objects in Netscape 4 is very tricky, as it doesn't allow you to search the tree, you need to travel through it yourself. This here is an example of how to do this, one of my first applications of recursion.
The W3C Document Object Model 1
This is a rather lengthy article, which talks about the Document Object Model, and how one can create Dynamic HTML in it. It's mostly for people who've never done anything but Internet Explorer 4, and Netscape 4 coding before. These people are thankfully very rare these days.
This is mostly things, that doesn't really fit anywhere else, but that I still want to have a place on the page.
SML is a very popular functional language. Coming from Windows, my favorite editor, UltraEdit, has the great ability syntax color any file loaded into it. It just needs another file, to tell it how to do this, for each language. Since I could find no wordfile online, I made my own, and offer it here. It's very basic, but should be better then nothing. It also has a regex, for parsing out the functions, so the function list, in UltraEdit should work too.
Various papers I've written while attenting university, and various articles I've found, and read during my courses. Linked or put online, where copyright allows to.