I was just exploring a template and saw that they have empty javascript:{} in href attribute. It didn’t seem to do much. Is this is just a place holder or some kind of comment that this nav works with javascript?
Please note that it was found in vav links that had unordered lists like below.
yeah it looks like it doesn’t do anything. I was wondering why putting this (javascript:{}) or even a # is better than keeping it empty? is it Just to make it readable?
If you click a link with an empty href you get an error, while clicking a link with # as the href value just jumps you to the top of the page, so the latter is better.
Edit:
Hm, I thought that was the case, but thought I’d better test it, and it wasn’t so—no error message when the href is empty. But still …
… the real question is—why have a link on your page with either of these? If the link has nowhere to go, it shouldn’t be a link.
I always use #, because I’ve gotten errors in the past having nothing in there.
You know that.
I don’t know how you go about designing. A lot of people do have hrefs with just # in them—because the link bahavoir is controlled by JavaScript. However, that’s lousy coding, as those links are useless with JS off—which is an indication of poor coding methodology.