Bitcoin Forum
June 21, 2024, 11:21:10 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Javascript problem in Firefox.  (Read 1236 times)
r3wt (OP)
Hero Member
*****
Offline Offline

Activity: 686
Merit: 504


always the student, never the master.


View Profile
June 20, 2013, 11:55:21 AM
 #1

Ok, i'm having problem getting this to work in firefox

this is a captcha i made using a devshed tutorial. this function is used to reload.
Code:
<script type="text/javascript">function reloadCaptcha()
{img=document.getElementById('captcha');img.src='captcha.php';}</script>


i'm using the following to call the function in an href

Code:
<a href="" onclick="reloadCaptcha();"></a>

this works perfect in chrome and in ie as well.

however i can't get it to work in firefox.

as a work around, i'm using
Code:
return: false;"
which works in firefox, but it refreshes the entire page in all 3 browsers and looks unproffesional in my opinion.

Code:
<a href="" onclick="reloadCaptcha(); return: false;">

i need to find a work around for this in 5 days or less. The site is ready for production and the owner has signed off on it, but i think i could do this a little better. i don't know much about ajax or jquery. i need a crash course or atleast a work around for this problem.

r3wt




My negative trust rating is reflective of a personal vendetta by someone on default trust.
RoadToHell
Sr. Member
****
Offline Offline

Activity: 260
Merit: 250



View Profile
June 20, 2013, 03:07:56 PM
 #2

should be
    return false;
not
    return: false;


That should prevent the page reload.  If not, try using setTimeout to call reloadCaptcha in the onclick attribute.

Sam Spade: We were talking about a lot more money than this.
Kasper Gutman: Yes, sir, we were, but this is genuine coin of the realm. With a dollar of this, you can buy ten dollars of talk.
r3wt (OP)
Hero Member
*****
Offline Offline

Activity: 686
Merit: 504


always the student, never the master.


View Profile
June 21, 2013, 03:52:42 AM
Last edit: June 21, 2013, 04:08:45 AM by r3wt
 #3

should be
    return false;
not
    return: false;


That should prevent the page reload.  If not, try using setTimeout to call reloadCaptcha in the onclick attribute.


ok, thanks for the response. i will try your suggestions.

edit: i tried both methods, even with placing the reloadCaptcha inside the setTimeout but its still giving the same result but with it seems to be decreasing page load speeds


My negative trust rating is reflective of a personal vendetta by someone on default trust.
rethaw
Sr. Member
****
Offline Offline

Activity: 378
Merit: 255



View Profile
June 21, 2013, 04:18:43 AM
 #4

What about it doesn't work? Not to be snarky but why are you asking here and not stackoverflow?

Maybe try putting a # in your href.

Code:
<a href="#" onclick="reloadCaptcha();"></a>

🏰 TradeFortress 🏰
Bitcoin Veteran
VIP
Legendary
*
Offline Offline

Activity: 1316
Merit: 1043

👻


View Profile
June 21, 2013, 04:23:12 AM
 #5

<a href="#" onclick="reloadCaptcha()">

No ; at the end.

Better way if you want to use jQuery:

$("#linkid").click(reloadCaptcha);
RoadToHell
Sr. Member
****
Offline Offline

Activity: 260
Merit: 250



View Profile
June 21, 2013, 02:06:56 PM
 #6

If "return false;" is not preventing the page reload then an error is occurring in the javascript that executes before it reaches the return statement.

Sam Spade: We were talking about a lot more money than this.
Kasper Gutman: Yes, sir, we were, but this is genuine coin of the realm. With a dollar of this, you can buy ten dollars of talk.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!