0

I have some code on some of my links

<a class="nav_bu" onclick="switchType('all'); return false;" href="#">

when I click on them, I get fowarded to mydomain.com/# (404 error..).

How can I get the function activated, rather then the href link.

P.S. I have mod_rewrite running, is this screwing things up? Here are the rules that effect the root directory:

RewriteRule ^home/$ home.php [L]
RewriteRule ^inbox/$ inbox/inbox.php [L]

3 Answers3

16

I think you have an error in the switchType('all') function. That is why the browser does not get to return false; and uses the default action to redirect you to href.

Dan Herbert
  • 99,428
  • 48
  • 189
  • 219
Eldar Djafarov
  • 23,327
  • 2
  • 33
  • 27
  • Agree with this. I never had problems with the #. – OregonGhost Aug 13 '09 at 11:34
  • Agreed, the shown code is just fine, so there has to be an error in the function. Show Javascript errors: In IE enable "Display a notification...", in Firefox open the error console. – Guffa Aug 13 '09 at 11:47
3

use button instead of link

Kamarey
  • 10,832
  • 7
  • 57
  • 70
  • 1
    Agreed. Buttons should be buttons, links should be links. – James Wiseman Aug 13 '09 at 11:34
  • There is a point to that... However there is still an error in the functon that is called so it doesn't fix the root of the problem. – Guffa Aug 13 '09 at 11:55
  • right, but there is no more problem with '#', and you don't spend hours to find a bug in mod_rewrite rules:) – Kamarey Aug 13 '09 at 12:05
  • @Guffa: by the way, your answer on this question http://stackoverflow.com/questions/1133581/is-23-148-855-308-184-500-a-magic-number-or-sheer-chance is amazing! – Kamarey Aug 13 '09 at 12:07
0

First of all, you state, based on your tags, that you are using jQuery. Why would you be using inline javascript listeners then?

Try this:

$(function() {
    $('.nav_bu').click(function() {
        switchType($(this).attr('rel'));
        return false;
    });
});

If this is your HTML:

<a class="nav_bu" rel="all" href="#">Blah Blah</a>

But, yeah... like people are saying, you probably have a problem with your switchType function. Run the site in Firefox with Firebug installed and it should tell your right where you problem is.

KyleFarris
  • 17,274
  • 5
  • 40
  • 40