Hi LouiseMarie,
You could do several things, here's a few:
- drop the href="" attribute <a onclick="showdiv('fadedbg'); showdiv('popup');">My Tasks</a>
- use span instead <span onclick="showdiv('fadedbg'); showdiv('popup');">My Tasks</span>
- use a return value to test if Javascript is enabled
But of course, span tags don't have the nice :link, :visited, and :hover pseudo classes.
I always take advantage of <a> tags for this reason.
Since you're not actually navigating anywhere, the anchor tag <a> doesn't need the href="" attribute.
_______
The only reason I would use the href="" attribute in a similar situation is if I were accommodating users who don't have Javascript enabled.
Here's an example:
function showdiv(divid){
document.getElementById(divid).style.display="block";
return true;
}
<a href="javascriptless.html" onclick="return !(showdiv('fadedbg') && showdiv('popup'))">My Tasks</a>
Since I added "return true;" to your function, the onclick attribute is testing for "false".
This will test if the function works, and if not, then the href="" navigation is activated...and they are sent to "javascriptless.html", or anywhere for that matter.