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 8007647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:53:58+00:00 2026-06-04T17:53:58+00:00

The following code sample adds a semi transparent 100% overlay when a button is

  • 0

The following code sample adds a semi transparent 100% overlay when a button is clicked. The overlay remains until the mouse button is released. Here’s what is supposed to happen:

  • Click on the button and hold the mouse down.

  • While the mouse is down press and release the shift key.

  • When it’s pressed, a div area
    indicates this with the text “horizontal” and the cursor changes to
    e-resize. When shift is released, the div indicates “vertical” and
    the cursor changes to n-resize.

In IE9/10, the text changes but the cursor remains the same. I’ve tried changing the key bind to the body level and to the overlay level but to no avail.

Here’s the code: (I tried putting it into jsfiddle and jsbin but for some reason they ignore the key presses completely).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <style type="text/css">
        .overlay {
            background-color: rgba(0, 0, 0, 0.3);
            top: 0; bottom: 0; left: 0; right: 0; position: fixed;
            z-index: 999;
        }
        .vertical { cursor: n-resize !important; }
        .horizontal { cursor: e-resize !important; }
    </style>

    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {

            $("#button1").mousedown(onButtonMouseDown);

            function onButtonMouseDown(e) {

                var overlay;

                overlay = $("body").after("<div class=\"overlay\"></div>").next();
                overlay.addClass((e.shiftKey) ? "horizontal" : "vertical");

                $(document).bind("keydown.ntextbox", function (e) {
                    if (e.which === 16) {
                        overlay.removeClass("vertical").addClass("horizontal");
                        $("#div1").html("horizontal");
                    }
                });

                $(document).bind("keyup.ntextbox", function (e) {
                    if (e.which === 16) {
                        overlay.removeClass("horizontal").addClass("vertical");
                        $("#div1").html("vertical");
                    }
                });

                overlay.mouseup(function (e) {
                    overlay.remove();
                    $(document).unbind(".ntextbox");
                    return false;
                });

                return false;
            }

        });
    </script>

</head>

<body>
    <div id="div1">...</div>
    <button id="button1">Click me</button>
</body>
</html>
  • 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-04T17:53:59+00:00Added an answer on June 4, 2026 at 5:53 pm

    Adding the following jQuery statements seems to fix it.

    $(".overlay").css("cursor", "e-resize");
    $(".overlay").css("cursor", "n-resize");
    

    So, maybe something like this?

      $(document).bind("keydown.ntextbox", function (e) {
           if (e.which === 16) {
               overlay.removeClass("vertical").addClass("horizontal").css("cursor", "e-resize");
               $("#div1").html("horizontal");
           }
      });
    
      $(document).bind("keyup.ntextbox", function (e) {
           if (e.which === 16) {
               overlay.removeClass("horizontal").addClass("vertical").css("cursor", "n-resize");
               $("#div1").html("vertical");
           } 
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Writing a code that does the following: Adds a mouse listener to a web-page
The following code sample (also at http://jsfiddle.net/MZwBS/ ) var items = []; items.push({ example:
The goal of the following code sample is to read the contents of $target
Given the following code sample: uint8_t i, in, ni; i = in = 2;
I have the following code sample that im trying to wrap my head around
I have the following code sample: float val = 16777216.0F; var badResult = Convert.ToDecimal(val);
I have the following sample code which doesn't seem to want to run. import
I have a Dictionary bound to DataGridView by using following sample code. DataGridView bound
I am new to Emacs, and I have the following code as a sample.
Following code is from a sample of playframework-2.0: /** * Display the dashboard. */

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.