All entries for Wednesday 23 November 2005

November 23, 2005

More rubbish javascript

Follow-up to An open gripe at the people behind blogbuilder's javascript from Draknek's Deprecated Devlog

While trying to add a tag to it, I managed to bump my last post on this subject to today's date. Not quite what I wanted. So the previous entry should really be my second post, on September 28th.

Today's unusability comes from the Student's Union voting page, which I'm sure large numbers of people will be visiting.

Once more, we have people trying to be very clever by opening new windows in javascript. This time, however, there's not even a good reason for it.

If someone wants to open a 300×200 pixel window, then that's a reason to use javascript. I might disagree about whether it was necessary or not, but I couldn't dispute that javascript is the way to achieve it.

If, on the other hand, someone wants to open a new, full-size window, I would have difficulty making the case for a javascript solution. Extreme difficulty.

Here is the very nice, very standard, very usable HTML solution:

<a href="URL goes here" target="_blank">Read Motion Document</a>
And here is an example link from the page (with the horrible mouseover statusbar text removed for the purposes of a fair comparison):
<a href="javascript:void(0);" onclick="javascript:Main_Win('URL goes here',
'referendum','yes'); return true;">Read Motion Document</a>

The href attribute (absolutely the most important part of the tag) contains javascript code to do nothing. And because of this, anybody who middle-clicks the link to open it in a new tab, gets a blank tab. Anybody with javascript disabled, or not using a browser with javascript support (screenreaders?), cannot open the link.

How hard would it have been to just put the URL in? Use javascript in stupid places all you like, but just don't mess with the href attribute!

There are two other silly bits to this. The first is in their code:

function Main_Win(url,name,scrollbars) {
window.open(url,name);
return true;
}

Which completely ignores the scrollbars variable.

The second just makes me wonder what whoever designed this was thinking. For each motion, there are three links: "Read Motion Document", "Read Case For", and "Read Case Against". Looking at the code, I see that the first link should open in the frame referendum, and the other two should open in the frame referendum_case.

For our purposes in this case, a frame can be thought of as just a window or tab. Opening a link in a named frame will create a new window with that identifer. If you try to open a link in a frame that is already open, then you will replace the previously open page.

This means that you can only have one of For or Against open at once. Opening one of them will replace the other. This applies across all three motions, too: all the Motion Documents will load in the same page.

For the user, this has got to be confusing. Some links open in one different window, while others load in a second different window.

(My HTML version code should really have had target="referendum", but the sensible way to open new windows is with _blank, which corresponds to a new window/tab.)

—-

Just to be fair, the Student's Union Societies section uses javascript in a very sensible fashion. Clicking on any group of societies will drop down a list of all societies in that group, but at no point is predictability lost. I can middle-click to my heart's content.

Finally, I note that it's been almost two months since I posted my BlogBuilder javascript complaint, and one of the problems I mentioned was fixed very quickly. However, the other one, which I find more annoying on a day-to-day basis, remains.

This is the code as it currently is:

<a href="javascript:showWindow('URL goes here','false',450,500,'viewComments');"
title="Read or add comments">
And this is how easy it would be to fix:
<a href="URL goes here" onclick="showWindow('URL goes here','false',450,500,
'viewComments'); return false;" title="Read or add comments">

I promise if it gets fixed I won't write any more stuff about bad javascript until next term.

(So much for an early night…)


An open gripe at the people behind blogbuilder's javascript

Seriously bad form on the javascript front.

These things need to be accessible! I spent the last several days using Mac OS 9 (for reasons I won't explain right now) and found myself completely unable to update this.

The "Create entry" link contains an acceptable drop-down menu in most browsers. For some reason, this doesn't work under Mac IE. This I don't really care about; nobody is really expected to test in Mac IE any more.

The problem is that when this drop-down menu does not appear, the link becomes pointless. There's no reason not to link it to the main "new entry" page, and some very strong accessibility arguments for doing so.

Another example of this is in the comments link at the bottom of each entry. It uses a javascript: URL to open a new window with the comments in it. Unfortunately, this means that when I try to open it in a new tab (we're back with a decent browser now), all I get is a blank window with a useless javascript URL in the address bar.

Once again, you make sure the link is accessible by making sure the URL actually goes somewhere. This means moving the javascript to where it was meant to be: the onclick event. But it means that I can middle-click to my heart's content, and anybody wandering around with javascript disabled (for whatever reason) will face no obstacle at all.

P.S. The rest of it I like.


New blog location

After a hiatus of several years, I’ve started blogging again at blog.draknek.org.

My website

Looking for more information about Alan Hazelden? Follow me on Twitter or go to my website.

November 2005

Mo Tu We Th Fr Sa Su
Oct |  Today  | Dec
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30            

Search this blog

Blog archive

Loading…

Most recent comments

  • Knife game: No actual cutlery involved. A single player starts with the "knife" by clasping his or h… by Noyb on this entry
  • My friends and I have taken to this one very silly game lately that's probably altogether too insula… by Ian S. on this entry
  • Great, thanks for those! That first one I would know by the name of Wink Murder, usually with a sing… by on this entry
  • I don't know the names for these games, so I'll make them up: Sniper. Randomly choose who is the sin… by zep on this entry
  • I recommend checking out Project Sprouts from Luke Bayes. It makes obtaining and configuring the fla… by Duncan Beevers on this entry

Tags

Not signed in
Sign in

Powered by BlogBuilder
© MMXVIII