Fix tab logic for dataset javascript.

It behaved differently on Chrome and Firefox.