Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2005, 08:23 AM
Authorized User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default ShowModalDialog

Hi

New to ASP and Javascript so be gentle if this is a stupid question.

I have an asp page that is used for user confirmation (ID/Password) that is called at various points in a web application based on an intranet.

The page contains two input fields, user id (defaulted to current user) and password and two buttons (accept and cancel)

I am trying to give focus to the password field on load and have a single line javascript function called "onload=" as

document.opcheck.txtPassword.focus();

The issue I am having in inconsistency with actually gaining focus in the password field.

Using my own machine as server and client I cannot get focus in the field. By dialing onto a customer site and running the exact same software, the focus in the password field on load is obtained. If the users on the site try they do not get the focus (This is the reason for testing and this thread).

The only difference I have noticed is that on my machine I do not get a status bar at the bottom of the dialog box but using the software on site I do (using the default for status).

Other testing involved adding a window.alert in the onload function before the ...focus line. If the alert is removed quickly then I do not get focus, if the alert remains for a few seconds then focus is obtained.

I cannot give a link etc to test as all the software/DB is intranet based although I have tried to supply as much information as possible. If there is any thing I have missed please let me know.

Any ideas or avenues of testing would be appreciated.

Thanks in advance

Darren
(IE 6 SP2, IIS 5.1, ASP)
Reply With Quote
  #2 (permalink)  
Old February 15th, 2005, 01:08 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Hi,

 Can u paste the login code which u are using?

Om Prakash
Reply With Quote
  #3 (permalink)  
Old February 15th, 2005, 01:45 PM
Authorized User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

login Code ?

Are you looking for the code that calls the modal dialog or some other section of code ?

The dialog is called from a javascript function

    function OpCheck2(strLevel,strTask) {
        var features;
        features = 'dialogHeight:210px;dialogWidth:380px;center:yes;h elp:no;resizable:no;status:yes;scroll:no';
        return window.showModalDialog('/express/security/opcheck2.asp?level='+strLevel+'&task='+strTask,'', features);
    }


HTH

Darren

Reply With Quote
  #4 (permalink)  
Old February 15th, 2005, 07:54 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

If you want to get focus on load of the page, then this should work:
<body onLoad="this.document.form1.a.focus();">

Still, i am not clear when u say "inconsistency".

Are u trying to get focus in password field, when the ModalDialog is closed?

Om Prakash
Reply With Quote
  #5 (permalink)  
Old February 16th, 2005, 05:26 AM
Authorized User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The password field is the second field on the modal dialog (with user id being the first)

As 9 times out of ten the user id will be correct for the person using the machine I want the focus to be on the password field when the modal dialog is displayed.

The inconsistency is that dependant on client / server sometimes it works and others it doesn’t.

Eg. If I use my machine as both server and client I cannot get focus on the password field. If I use my machine as client only and connect to the customer sites server then I can get focus on the password field and it works. If the users on site try and connect to their server then they cannot get focus.

The browser and software running on the server are identical in all cases.

One thing I have noticed is that if I Alt-Tab to another open application the Alt-Tab back the password field then has the focus. Is there anything that could remove focus from the modaldialog as a whole? ie. could the focus return to the calling screen ?

Regards

Darren
Reply With Quote
  #6 (permalink)  
Old February 16th, 2005, 01:14 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

You can add the following for the focus return to the calling screen:

<body onload="this.focus();">

Om Prakash
Reply With Quote
  #7 (permalink)  
Old February 16th, 2005, 01:21 PM
Authorized User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem with focus is on the modaldialog screen and not returning to the calling screen. When it is displayed the user then has to click into the password field instead of the cursor already being there.

Regards

Darren
Reply With Quote
  #8 (permalink)  
Old February 17th, 2005, 11:59 AM
Authorized User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I have found the cause but not a solution.

It seems to be the lines that enables remote scripting :

<script language="JScript" src="../_ScriptLibrary/rs.htm"></script>
<script language="JScript">
   RSEnableRemoteScripting("../_ScriptLibrary");
</script>

If I comment out the RSEnableRemote....... then I can get the focus in the field. (although RSExecute is used in onsubmit)

How could the RSEnable.... be stoping the focus in the field ?

Darren
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
showModalDialog Problem akhilesh_g Javascript 0 July 14th, 2008 06:43 AM
showModalDialog box dotnetuser ASP.NET 2.0 Basics 0 August 21st, 2007 11:46 PM
showModalDialog() leion General .NET 3 June 6th, 2004 04:08 PM



All times are GMT -4. The time now is 10:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.