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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:03:53+00:00 2026-06-01T09:03:53+00:00

Remember imagemaps? They were all over the place in the 90s. A webpage would

  • 0

Remember imagemaps? They were all over the place in the 90s. A webpage would have an image on it, and when you clicked on it, it could take some action based on not just the image, but the exact pixel that you clicked.

Now, let’s say that I’ve got some text in a div, rendered in a monospaced font, arranged as a 2D grid. Is there any way to put some Javascript on the div so that if I click on any character in that grid, it’ll trigger a script and give it the index of the character I clicked on?

I know I could brute-force this by surrounding every single character in the grid with its own customized <a> tag, but is there any simpler way to do it?

  • 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-01T09:03:55+00:00Added an answer on June 1, 2026 at 9:03 am

    Here’s a jsfiddle that proves the concept and seems to work. Each click will log to the console the matrix index of the letter clicked. (it’s 0-based and column, row)

    • Put your text into a monospaced grid
    • attach a handler to the onClick of the containing element
    • Compute the dimensions of a single letter (such as “m”) using a hidden element with just 1 letter
    • divide event.clientX and event.clientY by the dimensions of a single letter to get the coordinates of your clicked letter within your text

    See also calculate text width with javascript.

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

Sidebar

Related Questions

I remember, some time ago, seeing an example on MSDN of how you could
I remember seeing in the past a program that would take any file and
I remember seeing someone use a function in Oracle where they could specify a
I remember hearing somewhere that large functions might have higher execution times because of
I remember reading something once, but could not find it now while searching, if
I remember seen some code xaml where can get the first element (like an
I remember stumbling upon a method that would tell you when a view was
I remember this was possible in emacs, but don't know how. If I have
I remember there were some kind of fancy, super-special CALayer types or classes for
I remember eclipse and idea have this template to automatically create an object's hashCode

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.