Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:08:51+00:00 2026-06-09T21:08:51+00:00

I have some HTML that looks something like this: <div id=zoomed style=display:none; position:absolute;> <a

  • 0

I have some HTML that looks something like this:

            <div id="zoomed" style="display:none; position:absolute;">
            <a href="#" alt="close" id="closeLink" onclick="closeZoom();" tabindex="2"><img alt="close" style="border-style:none" class="close" id="closeButton" src="Images/trans.png"/></a>
            <div class="zoomParent">
            <table>
                <tbody data-bind="with: currentFactor">
                    <tr><td class="zIngHeader" colspan="3">
                    <span data-bind="text: FactorName"></span>
                    </td>
                    </tr>
                    <tr>
                        <td class="zMin" data-bind="text: formatValues(Min)"></td>
                        <td><input type="text" data-bind="value: currentValue" class="channel" onkeydown="EnterToTabHack(event);" tabindex="1"/></td>
                        <td class="zMax" data-bind="text: formatValues(Max)"></td>
                    </tr>
                    <tr><td colspan="3" class="graphCell" data-bind="animateColor: $root.statusColor"><div id="zoomPlot" class="zoomPlotStyle"></div></td></tr>
                </tbody>
            </table>
            </div>
        </div>

Now, when you are in the text box and you hit the tab key, the anchor tags gets focus, so if you immediately hit enter, you’ll run the function closeZoom(). This works fine.

What I want to do is have so if you are in the textbox and you hit enter, it will behave the same way as if you hit tab. So I have a function to do this:

    function EnterToTabHack(event) {
        if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
            $(".channel").blur();
            $("#closeLink").focus();
        }
    }

The blur part works fine, the value in the textbox gets written back to my viewmodel as I wanted, but the focus doesn’t end up on my link. Hitting enter twice should accept the value in the textbox (which is does) and then close the window (it doesn’t).

Any idea what might be wrong here? I see no error messages, but clearly the focus isn’t on the anchor link like it would be if I hit tab (note: just blurring doesn’t seem to do it either).

Edit: I’ve added a little more of the html because it may, or may not, be relevant. In particular, I’m using KnockoutJS for data binding and I think that is making it impossible to use the type of jQuery bindings (of events) that several people have suggested, or at least, if I were to use them, I’d have to rebind then every time “currentFactor” changed because I think what knockout is doing is destroying everything in the body of the table and recreating it when that part changes.

Another Edit: First, a really big thanks to everybody who has tried to help so far! I really appreciate you taking the time to take a look at this.

I played around and put together a JS Fiddle:

http://jsfiddle.net/sUh8G/4/

At first I was confused because, of course, it worked fine! Then I added the styles for the img and it seems that using sprites this way is what breaks it. If you remove all the img styles from the css, it works fine. With them, I can’t focus it programmatically.

Anybody seen anything like that before?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:08:52+00:00Added an answer on June 9, 2026 at 9:08 pm

    Ok here is a simplified fiddle, I used the js code from one of the other answers. The focus seems to work on my current browser FF 14

    http://jsfiddle.net/ZKYc3/

    Here is a version that works in FF 14

    http://jsfiddle.net/ZKYc3/2/ this one has a alert when the closelInk is clicked. Double enter triggers the alert. Perhaps all you need to do is take the event handling out of the html and leave it up to jquery to take care of

    Update: see http://knockoutjs.com/documentation/event-binding.html

    I think you should probably follow that since you are using knockout

    Updated fiddle working

    http://jsfiddle.net/sUh8G/5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some HTML that looks like this, <div id=mb_contents style=visibility: visible; opacity: 1;
So I have some html that looks like the following: <div class='something unknown' id='something_unknown_1'>
I have some HTML that looks like this: <div> <div class=value> <a href=# class=clicker>Some
I have some HTML that looks like this: <div class=product> Content In Here <div
If I have some HTML that looks like this: <div id=text> This is some
I have some html that looks like this: <div class=block> <div id=item1></div> <div id=item2></div>
I have some html that looks like this: <div id=parent> <div id=child></div> </div> I
I have some existing code that looks something like this: [tag:cb cbid=12345 cbwidth=200 cbclassname=calloutbox
Okay, if I have a html document that looks a bit like this: <div
I have a page that looks something like this: ... <div class=container> <div class=info>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.