I use javascript:void(0)
.
Three reasons. Encouraging the use of #
amongst a team of developers inevitably leads to some using the return value of the function called like this:
function doSomething() {
//Some code
return false;
}
But then they forget to use return doSomething()
in the onclick and just use doSomething()
.
A second reason for avoiding #
is that the final return false;
will not execute if the called function throws an error. Hence the developers have to also remember to handle any error appropriately in the called function.
A third reason is that there are cases where the onclick
event property is assigned dynamically. I prefer to be able to call a function or assign it dynamically without having to code the function specifically for one method of attachment or another. Hence my onclick
(or on anything) in HTML markup look like this:
onclick="someFunc.call(this)"
OR
onclick="someFunc.apply(this, arguments)"
Using javascript:void(0)
avoids all of the above headaches, and I haven't found any examples of a downside.
So if you're a lone developer then you can clearly make your own choice, but if you work as a team you have to either state:
Use href="#"
, make sure onclick
always contains return false;
at the end, that any called function does not throw an error and if you attach a function dynamically to the onclick
property make sure that as well as not throwing an error it returns false
.
OR
Use href="javascript:void(0)"
The second is clearly much easier to communicate.
You can use this trick for converting fonts from px to em in your CSS:
body {
font-size: 62.5%; /* resets the page font size */
}
Then specify your font sizes like this:
p {
font-size: 0.8em; /* equals 8px */
font-size: 1.0em; /* equals 10px */
font-size: 1.6em; /* equals 16px */
font-size: 2.0em; /* equals 20px */
}
And so on. Then you can convert px to em for your layout at PXtoEm.com.
Best Answer
Here is my study about icons:
Considering the tag:
<link rel="apple-touch-icon" href="IMAGE-NAME" />
Considering the sizes:
57x57px
default size72x72px
iPad size114x114px
Retina / OperaImages:
'apple-touch-icon.png'
- at iOS, in this image will applied the 'Gloss' effect. On other OS'es, nothing happens.'apple-touch-icon-precomposed.png'
- This image will not receive any effectHere is the following tests on OS':
BlackBerry v6.0 or higher
- Only works'apple-touch-icon'
BlackBerry v5.9 or lower
- Not supportedAndroid 2.2 or higher
- Works both versionsAndroid 2.1 or lower
- Only works'apple-touch-icon-precomposed'
iOS 4.1 or lower
- Works both versionsiOS 4.2 or higher
- Works both versions and accept size attributes (and so, sizes different from57x57px
)Nokia's (probably S60 5th FP1 and higher, not fully confirmed)
- Some accept'apple-touch-icon'
OperaMini (SpeedDial Shortcut)
- Works both versions BUT must have at LEAST114x114px
(speed dial normally is200x200px
if i'm not mistaken.