467,907 Members | 1,434 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

speeding up response.

Claus Mygind
512MB
In an effort to make my apps run faster, I have started to embed a search feature into the html page with javaScript to call and execute an ajax routine. Everything works fine except for setting focus to the first (and only) input element.
Expand|Select|Wrap|Line Numbers
  1. //~~~~~ Display search box ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. function showPopSearch( ) {
  3.     if (  document.getElementById("popSearch").style.visibility == "hidden" ) {
  4.         document.getElementById("popSearch").style.backgroundColor = "#E4BF87";
  5.         document.getElementById("popSearch").style.borderStyle = "ridge";
  6.         document.getElementById("popSearch").style.borderWidth = "5px";
  7.         document.getElementById("popSearch").style.borderColor = "orange";
  8.         document.getElementById("popSearch").style.zIndex = "99";
  9.         document.getElementById("popSearch").style.visibility = "visible";
  10.         document.getElementById("popSearch").style.overflow = "hidden";
  11.  
  12. //to make this brief showGetSearch() is not shown here
  13.         showGetSearch( );
  14.  
  15. //I have to use this timeout or it will run right past the giveSeachFocus( )
  16.         var TimeoutID = setTimeout("giveSearchFocus()", 150);
  17.     }
  18. }
  19.  
  20. //~~~~~ Give Search element focus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  21. function giveSearchFocus(){
  22.     document.getElementById("SEARCH").select();
  23.     document.getElementById("SEARCH").focus();
  24. }
  25.  
  26.  
The problem is sometimes, the cursor is there instantaneously other times it can take several seconds for it to appear. The users are annoyed that they cannot start typing right away. How can I resolve this issue and always have the cursor appear right away?
Aug 11 '08 #1
  • viewed: 1414
Share:
11 Replies
gits
Expert Mod 4TB
can you confirm that the field has NO focus or is the focus just 'invisible' ... so you could type instantly ... but just don't notice the focus? this problem seems to be common and i never saw a solution ... but you could 'workaround' it with setting a border around focused fields or a background-color ... so that the focus could be easily noticed ... the cursor alone seems to be a not quite good indicator ... but may be someone has a better solution?

kind regards
Aug 11 '08 #2
Claus Mygind
512MB
It is visible, you just cannot type in it until the cursor appears.
Aug 11 '08 #3
gits
Expert Mod 4TB
then there are some synchronous requests like large js-libs, frames etc.? that might be loaded the same time?
Aug 11 '08 #4
Claus Mygind
512MB
when I try this

Expand|Select|Wrap|Line Numbers
  1.  
  2. document.getElementById("SEARCH").style.background-color = "yellow";
  3.  
I get this error.

invalid assignment left-hand side
[Break on this error] document.getElementById("SEARCH").style.background-color = "yellow";\n

But I was able to do this to verify that the cursor was red
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("SEARCH").select();
  2. document.getElementById("SEARCH").focus();
  3. document.getElementById("SEARCH").style.color = "red";
  4.  
Aug 11 '08 #5
gits
Expert Mod 4TB
it has to be:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("SEARCH").style.backgroundColor 
kind regards
Aug 11 '08 #6
Claus Mygind
512MB
Ok I got the back ground color established to check. I can now say that the cursor and color are both delayed.

I have also established that the problem occurs when switching from one type of search request to another. I have several places on each screen where a user can request (click on) a search i.e. they can click on the company Id or company name. The same number of parameters are sent to the search request in either case.

Expand|Select|Wrap|Line Numbers
  1. onmousedown="if (CheckForChange(this.form,'no')) {showPopSearch(event,'Client Id','10','8','client','by Id','id','no','client)};"
  2.  
  3. onmousedown="if (CheckForChange(this.form,'no')) {showPopSearch(event,'Client Name','60','50','client','by Name','Name','no','client)};"
  4.  
As you can see the calls are identical except for the parameters.

On the initial request the popup is instantaneous. But if the user then select a 2nd search request on a different link the delay will occur?

How can I track where the slowdown is occurring. I am using FireFox with Firebug, so I can see response when the page loads but not the execution time of the scripts after the page is loaded, at least I don't know how.
Aug 15 '08 #7
gits
Expert Mod 4TB
typically there are just two simultanous http-requests allowed ... does the problem occur with two or just more requests? you could either abort the running requests or just don't check every field aqainst the backend through preloading some more data ...
Aug 16 '08 #8
Claus Mygind
512MB
There would always be only one request running at the time.
Aug 18 '08 #9
gits
Expert Mod 4TB
?? how is this ensured ?? you just said that you could search something and simultanously search for another thing ... is it sure that any search is not started before an already started one has returned? does any errors occur in firebug during the requests or response-handlings?
Aug 19 '08 #10
Claus Mygind
512MB
Thank you for your kind reply. Sorry for the delayed response, I am not a full time employee so I do not read these posts everyday.

You ask how can I ensure that only one search occurs at the time. Well the search is initiated by the user by clicking on one of several buttons. They are not likely to click on a 2nd button before they have completed the first search. The action of clicking on a button brings up the dialogue box into which the user has to enter the requested search information i.e. enter clients name. Then they click another button on the dialogue box to start the search. This action brings a response to the search dialogue box or responds "no records found". Therefore it is unlikely that they would stop the action of the first search and start a second search.

Besides at this point I am the one testing why the response is slow. And I know that I am only calling on search at the time.

I think you have pointed me to an area to look at, that being what is happening in my code when I change search criteria. So I will continue my search in the code for the answer.
Aug 28 '08 #11
gits
Expert Mod 4TB
hmmmm ... with a popup it even shouldn't be a problem in case it is a window ... every window handles its own requests (as far as i know) ... when closing it the request should be aborted. so it may be that there is something 'strange' when constructing the request ... in case you find something and need help with it just post back here :)

kind regards
Aug 28 '08 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Snyke | last post: by
5 posts views Thread by joethis | last post: by
6 posts views Thread by Angel Faus | last post: by
2 posts views Thread by Robert Wilkens | last post: by
4 posts views Thread by Troy | last post: by
reply views Thread by Matt | last post: by
2 posts views Thread by simon_w3 | last post: by
5 posts views Thread by Simon | last post: by
3 posts views Thread by cj2 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.