SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to place the cursor in a particular position in a text box?

    Hi,

    I want to place the cusor in a particular position in a text box when click on button object.
    txtObject.focus() method will always place the cursor in the 1s position of textbox,but i want to place the cursor in 3rd position like that.How to do that.
    Can u pls help me to solve this problem.

    Thanks & Regards
    vivek

  2. #2
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    read up on this article:

    http://www.alexking.org/blog/2003/06...ng-javascript/

    that should explain it,
    -ALL
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site

  3. #3
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Hi ,

    I have checked that url ,but there they have specified the method to get and set cursor position in a text box. In my case, i have the cursor position in one variable . I want to place the blinking cursor in that particular position in text box onclick of one button..

    I have tried with txtObj.focus() , but whats happening is its always placing the cursor in the first position of the text box...

    Thanks
    Vivek

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here ya go - the function listed in section 5 (positioning the cursor) works:
    http://parentnode.org/javascript/wor...rsor-position/

  5. #5
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Hi ,

    Thanks yaar. Its working fine in IE ,but in safari it not working. can u pls help me fix that problem in safari browser...

    Thanks
    vivek.

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It might not be possible in Safari - at least according to the author of that function I posted. Sorry mate.

  7. #7
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Safari doesn't support that yet.

    Only IE/Win, Firefox, and Opera 8 support doing that kind of thing currently.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  8. #8
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Hi

    How can i do that in safari? Is there any equivalent mehtod in javascript which suits for safari browser to place the blinking cursor in particular position of text box..

    Thanks
    vivek

  9. #9
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No. Like I said, you can't do this in Safari (as of version 2.0).

    You could put in a feature request for Safari to support the Mozilla method of doing this. Opera already did.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  10. #10
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx a lot


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •