www.webdeveloper.com
Results 1 to 3 of 3

Thread: Timing issue?

  1. #1
    Join Date
    Aug 2006
    Location
    Michigan
    Posts
    17

    Question Timing issue?

    in the following function, as shown, the if does not retun with a true value and hence the .focus() does not execute.
    But, if I remove the two slashes from the alert and let it execute, the subsequent if block now works.

    The sdata array has a single value which is the same as the title input box.
    Running on Fedora V13 with Firefox.

    Any ideas?

    See below for more info!!

    Code:
          function searchdata()
          {
    	var target = document.getElementById('title').value;
    	var c = 0;
    	while (c < sdata.length)
    	{
    //alert(target.toLowerCase() + "_" + sdata[c].toLowerCase());
    	  if (target.toLowerCase() == sdata[c].toLowerCase())
    	    {
    		document.getElementById('title').focus();
    		break;
    	    }
    	  c++;
    	}
    
          }
    After writing this note, I did the following:
    I moved the alert to inside the If block and befor the .focus()
    strangely I got the same results, so it seemed that the .focus was not working without some prior delay??!!
    Then I moved it to just before the break, and this time there was NO focus observable in the window!! when I then pressed the tab key, focus appeared on the very first object (a radio button in this case).
    Definitely seems like a timing conflict between where the focus wanted to go vs where it was directed to go!!!
    Last edited by griffinmt; 11-26-2010 at 04:11 PM. Reason: Further input

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654

  3. #3
    Join Date
    Aug 2006
    Location
    Michigan
    Posts
    17

    Resolved

    Thanks for that reference. I had done a search before but probably couldn't see the forest for the trees!!

    Anyway, just by adding 'this' as a param for the onblur and adding a timeout in the function, problem is resolved!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles