Interesting little Java and Web things learnt this week

Java’s Collections.unmodifiableCollection doesn’t pass equals and hashCode to the backing collection. I’m surprised I haven’t come across this before!

The user-select CSS property allows you to prevent selection of certain content. As the link explains, it’s useful for preventing accidental selection of icons next to buttons. A certain well known UK high street electronics shop’s website also uses it to prevent text selection, presumably to prevent you copying product names into price comparison sites. It’s not reliable or widely supported though. The same effect can be had by doing a preventDefault (or return false) in the “onselectstart” event handler (again doesn’t seem to be standard).

Continuing on the theme of text selection, I find the auto highlighting of library URLs on hover on the cdnjs website quite useful. It’s achieved using the Selection capabilities of the DOM, which allows you to get or set the current selected text.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s