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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:38:20+00:00 2026-05-22T22:38:20+00:00

Is it possible to create html links out of text that is rendered in

  • 0

Is it possible to create html links out of text that is rendered in a canvas element?

  • 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-22T22:38:21+00:00Added an answer on May 22, 2026 at 10:38 pm

    There is no easy way. You will have to draw the link text onto the canvas and then check for mouseclicks. Here is a demo html page:

    <html>
    <head>
    <script type="text/javascript">
    var canvas = document.getElementById("myCanvas");
    var ctx;
    var linkText="https://stackoverflow.com";
    var linkX=5;
    var linkY=15;
    var linkHeight=10;
    var linkWidth;
    var inLink = false;
    
    // draw the balls on the canvas
    function draw(){
      canvas = document.getElementById("myCanvas");
      // check if supported
      if(canvas.getContext){
      
        ctx=canvas.getContext("2d");
        
        //clear canvas
        ctx.clearRect(0, 0, canvas.width, canvas.height);
        
        //draw the link
        ctx.font='10px sans-serif';
        ctx.fillStyle = "#0000ff";
        ctx.fillText(linkText,linkX,linkY);
        linkWidth=ctx.measureText(linkText).width;
        
        //add mouse listeners
        canvas.addEventListener("mousemove", on_mousemove, false);
        canvas.addEventListener("click", on_click, false);
    
      }
    }
    
    //check if the mouse is over the link and change cursor style
    function on_mousemove (ev) {
      var x, y;
    
      // Get the mouse position relative to the canvas element.
      if (ev.layerX || ev.layerX == 0) { //for firefox
        x = ev.layerX;
        y = ev.layerY;
      }
      x-=canvas.offsetLeft;
      y-=canvas.offsetTop;
      
      //is the mouse over the link?
      if(x>=linkX && x <= (linkX + linkWidth) && y<=linkY && y>= (linkY-linkHeight)){
          document.body.style.cursor = "pointer";
          inLink=true;
      }
      else{
          document.body.style.cursor = "";
          inLink=false;
      }
    }
    
    //if the link has been clicked, go to link
    function on_click(e) {
      if (inLink)  {
        window.location = linkText;
      }
    }
    </script>
    </head>
    <body onload="draw()">
    <center>
    <canvas id="myCanvas" width="200" height="200" style="border-style:solid;border-width:1px">Canvas not supported.</canvas>
    </center>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to create HTML lists such as ordered and unordered lists without
Is it possible to create the curved sail shape below using HTML and CSS
Is it possible in javaScript to create an html file in same directory ?
I woulk like to know if with HTML is it possible to create asynchronous
I'm having difficulty getting HTML.ActionLink() create correct links. When I am at http://localhost:49242/ My
Is it possible to create a django template that can be used (nested) inside
I would like to create links that have icons included in the link. For
I'm trying to create a regex so I can identify URLs in text. Possible
Lets say I am currently at: http://example.com/folder/page.html Is it possible to create a relative
ruby 1.9.2p290 rails 3.1.1 How to create a html element from controller in SLIM

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.