focus problem in showModalDialog

I

Iver Erling Årva

I have this window where I open a modal dialog window using the code:

newwin=window.showModalDialog(url, "popup", features)

where features are


dialogLeft:"+x+"px;dialogTop:"+y+"px;dialogWidth:"+w+"px;dialogHeight:"+h+"p
x;center:0"

In the window that opens I call a function - setVar() in the body onLoad
event.

The setVar() function contains the following code:

this.form.Name.focus();
this.form.Name.select();

but although the window seem to have focus, I cannot see the cursor in the
form.Name textbox, and if I try to type something nothing happens. If I do a
Alt-tab back to the other window and then back again to the modal window,
the cursor is blinking in the Name field and I can type as normal. What is
causing this behaviour, and what can I do to fix it?

Can anyone please help with this?

Thanks!
(e-mail address removed)

Windows XP SP1 IE6 SP2
 
T

Thomas Hoheneder

Hello,

I am using Windows XP SP1 IE 6 - but not SP2.
First of all: You don't need the select() function in order to set the
focus; focus() should be enough.
Second: I have tried the following example - according to your description -
and it works correctly.
The focus is in the text field and you can type any characters within it.


page1.html
---------------------------
<html>
<head>
<title>Page 1</title>
<script language="JavaScript">
function func() {
newwin=window.showModalDialog("page2.html", "popup",
"dialogLeft:50px;dialogTop:50px;dialogWidth:300px;dialogHeight:200px;center:
0");
}
</script>
</head>
<body>
<form>
<input type="button" value="please click" onClick="javascript:func()">
</form>
</body>
</html>


page2.html
---------------------------
<html>
<head>
<title>Page 2</title>
<script language="JavaScript">
function setVar() {
document.forms[0].Name.focus();
}
</script>
</head>
<body onload="javascript:setVar()">
<form>
<input type="text" name="Name" value="">
</form>
</body>
</html>


Maybe you want to try this. Hope this helps you.

Nice greetings from
Thomas
 
I

Iver Erling Årva

Hi!

I did sort'of know about the superfluous select(). I know focus() should be
enough. I just was a bit surprised that it didn't work.

But I found the problem causing this behavioiur. Strange noone else here
knew about it, but perhaps I gave a little sparse information to deduct that
this was the problem.

The problem is the somewhat faulty Sun java-plug in 1.4.1 which causes this
strange behaviour. Sun knows about this according to my sources, but
apparently don't bother to do anything about it. Swithching back to the MS
Java engine fixed the problem.

Thanks for your kind help! Your tip is duly noted ;-)

Brgds
Iver in Oslo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top