jquery - javascript taking # marker literally - Stack Overflow

admin2025-04-26  9

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/# (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]

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./# (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]
Share Improve this question asked Aug 13, 2009 at 11:30 fsdkfjfsdkfj
Add a ment  | 

3 Answers 3

Reset to default 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.

use button instead of link

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745666046a313036.html

最新回复(0)