SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict delpino's Avatar
    Join Date
    Nov 2001
    Location
    London
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    set focus in Opera Browser

    Hello,

    I succeeded with this javascript code in IE and Firefox:

    document.form1.msg.focus()

    But doesn't seem to work in Opera, anybody knows why? Thanks
    http://www.antosch-and-lin.com - Language Learning

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You haven't posted enough of the code to be able to figure it out.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    focus

    without seeing more of the code, just a guess. Maybe if you tried something like
    Code:
    var form_msg = document.getElementById('msg');
    form_msg.focus();

  4. #4
    SitePoint Addict delpino's Avatar
    Join Date
    Nov 2001
    Location
    London
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like this:

    Code:
    <script language="JavaScript" type="text/javascript">
    
    function setFocus() { document.form1.msg.focus() }
    
    </script>
    
    <body onLoad="setFocus()">
    
    <form action="chat-input.php" name="form1">
    
    <input type="text" name="msg" size="50">
    <input type="submit" value="Send Message">
    
    </form>

    The code from Mittineague doesn't seem to work.
    http://www.antosch-and-lin.com - Language Learning

  5. #5
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    delpino, the code you posted works fine in Opera 8.5

  6. #6
    SitePoint Addict delpino's Avatar
    Join Date
    Nov 2001
    Location
    London
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are right, I tested just this code and it works. But not in my script where it is in a frameset. That might be the problem.
    http://www.antosch-and-lin.com - Language Learning

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Is the field in the same frame as the frame where the focus is being set?
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  8. #8
    SitePoint Addict delpino's Avatar
    Join Date
    Nov 2001
    Location
    London
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes it is..
    http://www.antosch-and-lin.com - Language Learning

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    A link to the page where the problem is occurring might help me to determine why it doesn't work.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  10. #10
    SitePoint Addict delpino's Avatar
    Join Date
    Nov 2001
    Location
    London
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Go here: http://www.bookmark-manager.com/help

    Start the Live Chat .. after that have a look in the bottom frame
    http://www.antosch-and-lin.com - Language Learning


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
  •