focus problem in showModalDialog

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Iver Erling Årva

    #1

    focus problem in showModalDialog

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

    newwin=window.s howModalDialog( url, "popup", features)

    where features are


    dialogLeft:"+x+ "px;dialogTop:" +y+"px;dialogWi dth:"+w+"px;dia logHeight:"+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!
    iver@tda.no

    Windows XP SP1 IE6 SP2


  • Thomas Hoheneder

    #2
    Re: focus problem in showModalDialog

    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="JavaS cript">
    function func() {
    newwin=window.s howModalDialog( "page2.html ", "popup",
    "dialogLeft:50p x;dialogTop:50p x;dialogWidth:3 00px;dialogHeig ht:200px;center :
    0");
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" value="please click" onClick="javasc ript:func()">
    </form>
    </body>
    </html>


    page2.html
    ---------------------------
    <html>
    <head>
    <title>Page 2</title>
    <script language="JavaS cript">
    function setVar() {
    document.forms[0].Name.focus();
    }
    </script>
    </head>
    <body onload="javascr ipt: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


    Comment

    • Iver Erling Årva

      #3
      Re: focus problem in showModalDialog

      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

      "Thomas Hoheneder" <thomas.hohened er@gmx.de> skrev i melding
      news:ckhkq4$8kl $1@domitilla.ai oe.org...[color=blue]
      > 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[/color]
      description -[color=blue]
      > 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="JavaS cript">
      > function func() {
      > newwin=window.s howModalDialog( "page2.html ", "popup",
      >[/color]
      "dialogLeft:50p x;dialogTop:50p x;dialogWidth:3 00px;dialogHeig ht:200px;center :[color=blue]
      > 0");
      > }
      > </script>
      > </head>
      > <body>
      > <form>
      > <input type="button" value="please click" onClick="javasc ript:func()">
      > </form>
      > </body>
      > </html>
      >
      >
      > page2.html
      > ---------------------------
      > <html>
      > <head>
      > <title>Page 2</title>
      > <script language="JavaS cript">
      > function setVar() {
      > document.forms[0].Name.focus();
      > }
      > </script>
      > </head>
      > <body onload="javascr ipt: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
      >
      >[/color]


      Comment

      Working...