473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

execScript focus problem (IE specific)

2
I'm using an Ajax call to open a search box in the page and I want the focus to go to the box automatically.

So, in the httpObject.responseText, I tried sending the following in addition to the search box markup:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. document.getElementById('Message').focus();
  3. </script>
and, after writing the response using innerHTML, the originating Ajax function calls an eval function to enable the JavaScript, the critical line being:

Expand|Select|Wrap|Line Numbers
  1. if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
It works in Firefox and Safari because they default to the window.setTimeout method. The problem is (as usual) Internet Explorer...

1. The JavaScript executes just fine - the focus goes to the search box - if I open the code of the search box directly as a page. I tried other ways of setting the focus which worked similarly but also failed similarly when using window.execScript.

2. I've tried other things in place of focus() and they all worked. A simple alert works, writing text to the box works but the focus is never set.

3. I found that if I included an alert in the eval function, the focus WOULD be set after I clicked OK. But that's clearly defeating the purpose of saving the user a click.

I doesn't actually bother me that IE users would get an inferior experience but this is such a curious problem I really want to know the answer.

Are there any IE experts here that can tell me?
Nov 6 '08 #1
1 3089
Drelus
2
I pressed on with my coding and I've just noticed that focus is now working in IE.

I've no idea what was wrong before.
Nov 6 '08 #2

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

Similar topics

0
by: gcash | last post by:
OK, I was writing code using WIN32ALL to do automation scripts for common things we do in IE a lot at work, since grunt-n-point gets very boring after a while. I snarfed the code from ...
20
by: Arne | last post by:
During testing <div style="overflow:auto;"> in CSS I noticed the mousewheel would work in Mozilla only after I made a <a href="#">some text</a> link and clicked on that, within the div. It...
0
by: Bhavin | last post by:
I m using execscript function to call a function that returns me an index. When I say return(index) in javascript, I want that Index in my C# code. How can I return a parameter from javascript to...
1
by: Rasmus | last post by:
I need to grab focus to a specific node i my treeview when I click on my listbox. Here's the code that differs between the different event i the listBox: private void...
3
by: ABC | last post by:
How to set first focus on specific textbox?
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
7
by: =?Utf-8?B?dmJ0cnlpbmc=?= | last post by:
I am using a switch statement, to check for valid user hours. If the hours control is blank, I want to place the cursor back to the hours control for the user. The following code does NOT work:...
1
by: orico | last post by:
Hello all, I have a few '<input type="text" />' controls on my ASP.NET 2.0 generated page. Every text-box control has it's specific tab-index. When I try to move focus to this specific text-box...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.