Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,960
    Thanks
    120
    Thanked 76 Times in 76 Posts

    focus remains on control despite focus changed

    select text, click color change:
    http://www-archive.mozilla.org/editor/midasdemo/

    How is that done, that is, the focus is transfered elsewhere (color picker), but text still remains selected. How does that work ?

    Need to do the same without iframes.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,628
    Thanks
    0
    Thanked 648 Times in 638 Posts
    being selected and having the focus are two entirely different things.

    mytext.selected() is completely different from mytext.focus()
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,960
    Thanks
    120
    Thanked 76 Times in 76 Posts
    so, I have:
    Code:
    <div contentEditable ="true" ...
    and selected text inside that.

    Code:
      <img src = '...'  onclick = "document.execCommand('underline')" />
    Clicking there works, the text inside div stays selected and becomes underlined;

    I have span, onclick it produces js generated color picker. And at that moment (clicking) text get deselected. Way around that ?

    Edit: If I replace span with img, selected text is not deselected ! But unfortunately it gets deselected, selecting color in color picker. ...
    Last edited by BubikolRamios; 11-29-2012 at 08:34 AM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search


  •  

    Posting Permissions

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