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

  • SEARCH
  • Home
  • 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 6039719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:24:38+00:00 2026-05-23T06:24:38+00:00

Setup I’m making an HTML page that replaces the cursor with a div element.

  • 0

Setup


I’m making an HTML page that replaces the cursor with a div element. The Javascript is below. The div element is simply <div id="cursor"/>.

function fixCursor()
{
  var cPos = getCursorPosition();
  cursor.style="top:" + (cPos.y) + "; left:" + (cPos.x) + "; position:fixed; width:16px; height:16px; background-color:#DDDDDD; box-shadow: 2px 2px 4px rgba(0,0,0,.5); border:2px solid #111111; border-radius:0 100% 100% 100%;";
  return;
}

function getCursorPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    }
    else if (e.screenX || e.ecreenY) {
        cursor.x = e.screenX;
        cursor.y = e.screenY;
    }
    else if (e.x || e.y) {
        cursor.x = e.x;
        cursor.y = e.y;
    }
    else if (e.clientX || e.clientY) {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX;
        cursor.y = e.clientY;
    }
    return cursor;
}

Problem


This only works on Opera, and shows signs of working on IE, but doesn’t show the cursor. On Firefox and Chrome, nothing appears. I haven’t tried Safari, as I uninstalled it a while ago, but in my experience, its rendering works alot like Chrome, anyway.

  • 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-05-23T06:24:39+00:00Added an answer on May 23, 2026 at 6:24 am

    In your code, getCursorPosition takes an event object, e. In fixCursor, you are not passing anything in. You should probably make fixCursor take an event object as well and pass it through to getCursorPosition. Then, in your event handler where you’re presumably calling fixCursor, pass in the event object passed into your event handler.

    Also, you cannot set style equal to a string. You can, however, set style.cssText.

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

Sidebar

Related Questions

Setup: I have an HTML page with a fieldset element. The background color of
Setup: I'm opening a new window via js that is a classic asp page
Setup I have a website that draws RSS feeds and displays them on the
Setup: I have a COM DLL that calls a method inside a managed C#
Setup: I have two views that I need to respond to the touch event,
Setup: IIS7 serving ASP classic VB script code which generates a dynamic VSC page/file
Setup using a simple example: I've got 1 table ( Totals ) that holds
Setup: There is a ComboBox that is bound to a ObservableCollection. There is a
Setup I have an accordion layout containing a properties panel that nests two inner
Setup: I have several UITableViewControllers (tvc) that all instantiate a separate NSFetchedResultsController (frc). All

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.