do it 2 times???

This is a discussion on "do it 2 times???" within the JavaScript Forum section. This forum, and the thread "do it 2 times??? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 30th, 2007, 08:53
Junior Member
Join Date: Oct 2007
Location: China
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
do it 2 times???

HTML: Select all
<script type="text/javascript">

function blurEvent()
{
test();
return false
}

function clickEvent()
{
test()
return false;
}

function test()
{
    alert("you are wrong");
}

</script>
when there is a onblur Event on a text , it will run blurEvent(), when I press a button it will run the clickEvent,but when I click the text and then click the button(onclick+onblur) it gives me one alert(because the return false) by IE, but when I use the FireFox , it gives me 2 alerts(firefox dose not know return false ??).....
I just want to receive only one alert.... does anyone help me ??
(forgive my poor English make it is not clear....)

Last edited by c010depunkk; Oct 30th, 2007 at 09:50. Reason: added [html]
Reply With Quote

  #2 (permalink)  
Old Oct 30th, 2007, 10:44
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: do it 2 times???

When you place return false in a function it does not stop execution of queued up events.. It only stops execution of that function... In this regard, IE is actually doing the wrong thing - it should display both alerts...

You could try setting if you wanted to be a certain amount of time between alerts, you could try something like this... It will only display an alert if the last one was more than 1 second ago

HTML: Select all
<script type="text/javascript">

function blurEvent()
{
test();
return false
}

function clickEvent()
{
test()
return false;
}

var waitForMe = false; // this will tell us if there was an alert recently
function test()
{
    if (!waitForMe){
    alert("you are wrong");
    waitForMe = true; // set this to true so the alert won't run again until waitForMe is false
    }
setTimeout('waitForMe=false', 1000); // set back to false after one second.
}

</script>
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #3 (permalink)  
Old Oct 30th, 2007, 10:56
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,772
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: do it 2 times???

Isn't there a missing semi-colon? Shouldn't it be:
HTML: Select all
function clickEvent()
{
test();
return false;
}
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
horizontal list navigation breaks when load times are slow sch3dana Web Page Design 14 Mar 19th, 2008 12:56
Great times, sad, but need to go moojoo Webforumz Cafe 12 Nov 8th, 2007 14:03
lunch time, fun times welshstew Webforumz Cafe 17 Jul 13th, 2007 08:21
Deal-Times begemot Free Web Site Critique 8 May 22nd, 2007 07:20


All times are GMT. The time now is 05:48.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43