JavaScript debugging with Internet Explorer
Filed under: Computers, Javascript, Programming, Technology, Web Programming
JavaScript? If you don’t realise that’s a rhetorical question then go away now…
I had a simple script that worked fine in Firefox and Opera but not in
“class” is a reserved word in
The main difference is a prototype language does not have classes (which is why “class” is not a reserved word in Firefox or IE), objects are given functionality on a per instance basis.
All this is rather academic though. If you need to debug JavaScript in IE for whatever reason, get the debugger. And ignore the link that says there is a newer version available – it’s pointing to Visual Studio .NET 2003.
AJAX problems in IE
Filed under: Computers, Javascript, Programming, Technology, Web Programming
This worked well until I started getting an odd error from IE - "Unknown runtime error". Firefox and Opera both handled this fine. After some fiddling I discovered the problem was the type of element I was replacing into - Internet Explorer doesn't like you replacing the innerHTML of certain elements. So far I've found TR and TBODY don't work (and I'd guess THEAD and TFOOT too).]]>
An introduction to SALT
Filed under: Javascript, Languages, Programming, Technology, Web Programming
article about speech synthesis is an add-in for
To actually create speech enabled web pages, you need to use SALT.Speech Application Language Tags is now fairly standard and being supported by
The first requirement is to add the SALT namespace to your XHTML document:
<html xmlns:salt="http://www.saltforum.org/2002/SALT">
This probably isn’t a requirement but you should do it anyway.
The next thing you need to do is to load the add-in and tell it what to handle. This is definitely vendor specific and only applies to the add-in for
<object id="saltobject" classid="clsid:33cbfc53-a7de-491a-90f3-0e782a7e347a"></object>
<?import namespace="salt" implementation="#saltobject" />
All the code does is create an object and then tell it what namespace to look for SALT tags in (in this case the “salt” namespace). There is one potential sticking point. The standalone IE add-in is not the same as the one you get if you install the whole SDK so for debugging purposes the classid will be different.
After that it’s just a matter of adding the SALT tags for handling the speech. In this article I’ll just deal with the simplest one, prompts. A prompt is just a piece of speech. Just write your speech inside a <salt:prompt> tag:
<salt:prompt id="InstructionsPrompt">
Hello. Thank you for using this salt demo.
</salt:prompt>
The id can be anything you want as it is only used to uniquely identify the prompt. We now have to get around the semantic seperation of form and function: this simply defines a prompt and doesn’t actually do anything with it. To actually make it do something we have to use Start() function accessible from JavaScript so to make it play, just call InstructionsPrompt.Start(). Although it’s not an ideal solution for testing purposes just attach it to the onload event of the body tag.
You can see (and hear) the whole SALT demo.
A final note about voices.
Windows XP comes with a good voice called Microsoft Mike, but this may not be the default. Some of the others sound really bad. To set Mike as the default:
Start -> Control Panel -> Speech -> Text-to-speech
AJAXy Scriptaculous goodness
Filed under: Computers, Galaxia, Games, Javascript, MPOGs, Programming, Ruby on Rails, Technology, Web Programming
Scriptaculous is a Javascript library used for doing AJAX stuff and certain visual effects. It’s very well written, has excellent cross browser support and best of all there are cool functions in Ruby on Rails for using it.
One of the coolest features is drag and drop. I’ve already implemented it in Galaxia Ruby for adding ships to fleets
I have an interview
Filed under: Computers, Javascript, Life, PHP, Personal, Technology, Web Programming
Before they offered me a face-to-face interview they wanted to do a telephone interview first. This consisted of a series of technical questions I really wasn't prepared for ("What's the difference between an inner join and an outer join in SQL?", "What are the restrictions on cookies?", "What do the HTTP status codes 302 and 303 mean?").
But since they offered me the interview I guess I did quite well :)
(On an unrelated note, "Woohoo" is not in the Google spellchecker database but "Whoop" is....)
DOM foolery
DOM-foolery. It describes a relatively simple way to make images in web pages have curved corners.
How about Cash City Wars
Filed under: Games, Javascript, MPOGs, PHP, Programming, Technology, Web Programming
Reading style info with JavaScript
DIV and then puts it back as it was. Changing the style is easy. For example to make the text green:
// Some code to get the DIV object and store it in obj. obj.style.color = "green";
Storing the old style information is a little difficult. I tried:
obj.oStyle = obj.style; obj.style.color = "green";
But that didn't work for two reasons: firstly objects are passed by reference so oStyle always contained the same thing as style. And secondly style (when used for reading) only contains explicitly set properties. So if you set width and left you'd still have to work out right yourself.
I found out there is another property you can use, getComputedStyle. This has it's own little quirks however. Firstly it isn't an method of the object, but used more like a function and secondly it doesn't seem to work in IE6.
Firefox (W3 DOM):
temp = document.defaultView.getComputedStyle(obj, ""); temp.getPropertyValue(prop);
IE6
obj.currentStyle[prop];
I personally think the IE way makes more sense in this case but we have to cope wtih both. One thing that is slightly awkward is that one is a function the other is an array. So to make a simple to use interface to the correct function, we can use Javascript's ability to use functions as first class objects (which means you can assign them to variables):
if (document.defaultView) {
var cStyle = function(obj, prop) {
var temp = document.defaultView.getComputedStyle(obj, "");
return temp.getPropertyValue(prop);
}
} else if (document.body.currentStyle) {
var cStyle = function(obj, prop) {
return obj.currentStyle[prop];
}
}
You can now call cStyle like a normal function to get the computed value of any style property of any object.
Demo of GIS thing
Demo.
Target denied
The target attribute of a tags is no longer allowed in HTML (HTML 4.01 Strict and XHTML 1.0 Strict).
This is technically corect since HTML is for marking structure of a document and opening things in different windows is a user-interface issue and hence is within the domain of javascript.
What's really odd though is the suggested workaround. Mark tags that need to open in a different frame or window somehow (rel="external" for instance) and then use a javascript function to give all those links a target attribute.
Seems silly to me.
