admin管理员组

文章数量:1279234

I have an anchor that triggers a javascript which uses jquery:

<a href="javascript: $('#dash-main').load('billing.php')">text</a>

This anchor works fine in Chrome, and even in IE, but when I use it in FF, the browsers redirects to "http://javascript: $('#dash-main').load('billing.php')".

Any idea what is wrong?

I have an anchor that triggers a javascript which uses jquery:

<a href="javascript: $('#dash-main').load('billing.php')">text</a>

This anchor works fine in Chrome, and even in IE, but when I use it in FF, the browsers redirects to "http://javascript: $('#dash-main').load('billing.php')".

Any idea what is wrong?

Share Improve this question asked Aug 4, 2012 at 15:44 Dan SternDan Stern 2,1678 gold badges26 silver badges39 bronze badges 4
  • Consider connecting this to a function instead that calls it. – Robin Castlin Commented Aug 4, 2012 at 15:46
  • Remember to accept and answer to get that accept rate up. – iambriansreed Commented Aug 4, 2012 at 20:58
  • Can you link to an example? This is quite odd and unexpected behavior. – Boris Zbarsky Commented Aug 5, 2012 at 5:41
  • Don't use javascript: HREFs. Use the cross-browser onclick event. – user229044 Commented Aug 10, 2012 at 2:28
Add a ment  | 

3 Answers 3

Reset to default 10

Use onclick and avoid the problem:

<a href="#" onclick="$('#dash-main').load('billing.php');return false;">text</a>

Why not use:

<a href="#" onclick="$('#dash-main').load('billing.php')">text</a>

Cross-browser patible!

Did you try returning false?

<a href="javascript: $('#dash-main').load('billing.php'); return false;">text</a>

本文标签: href javascript jquery not working in FFStack Overflow