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…)


- 5 comments by 2 or more people Not publicly viewable

  1. Mathew Mannion

    I'm pretty sure that making all the popups more accessible has been on the BlogBuilder TODO list for quite a while…

    link

    23 Nov 2005, 07:40

  2. Happily this is now fixed and deployed :)

    Thanks for the reminder.

    23 Nov 2005, 11:24

  3. me

    'target' isn't a valid attribute in XHTML, so it isn't quite as clear-cut as you make out…

    23 Nov 2005, 19:27

  4. I had indeed forgotten that.

    I don't actually think we should be telling the browser to open links in new windows anyway, but I decided that wouldn't really be relevant to my post.

    Whenever I want a link to open in a new tab, I middle-click it. Otherwise, I'd like it to open in the current tab.

    Obviously, I'm not representative of the majority of internet users. But I don't think that websites should be making assumptions on the desired behaviour of these things.

    24 Nov 2005, 02:08

  5. I don't usually have any guilt with using target="_blank"... but that's a good point.

    01 Dec 2005, 15:24


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

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
© MMXIX