473,769 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

execScript focus problem (IE specific)

2 New Member
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.resp onseText, 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.setTimeo ut 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.execScri pt.

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 3118
Drelus
2 New Member
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
3030
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 <http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&newwindow=1&safe=off&selm=mailman.1034878702.25947.python-list%40python.org> which was very useful. (Thanks, Dave!) Finally I get to a beta stage and give it to some of the guys in my group to...
20
12306
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 appears as if Mozilla needs to have the focus set on that div in order for the mousewheel to work. That's all that link does. The mousewheel works perfectly in IE without the link. It scrolls the div even if there is a scrollbar on the page. Is...
0
1387
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 C#? Plz help. Its urgent.
1
15550
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 listBox1_SelectedIndexChanged(object sender, System.EventArgs e) { string selected; selected = this.listBox1.SelectedItem.ToString(); if(selected == "Error in Supercell 1") {
3
1307
by: ABC | last post by:
How to set first focus on specific textbox?
3
3986
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 a couple of problems, which I'll try to describe. But this e-mail will only reproduce one of them, in a "short" example. What I'm generally doing is having each form entry contained in a div, which as a label, an input with some event handlers,...
11
7346
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 1.7.12 (linux kubuntu). It does work with konqueror. It seems to work with firefox on windows but not with IE (not completly sure though).
7
1819
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: switch (txtHours.Text) { case "": MessageBox.Show("No hours entered.\nYou must enter hours
1
1552
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 control on this page the focus is shifted to the window element instead of the control itself. On every other text-box control on the page the focus is received fine. To apply focus to this element I use the code: document.all.elemName.focus(); ...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8870
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.