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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:15:13+00:00 2026-05-27T18:15:13+00:00

I have probably a quite easy question: I created a canvas on my HTML

  • 0

I have probably a quite easy question:
I created a canvas on my HTML page and did some painting stuff on it.
Now I want to put a normal p-Text object over this canvas.
However, when I do insert a new p-Element using the x|y mouse coordinates canvas.onmousemove(e) gives me and the position:absolute setting, my painting on the canvas gets “lost”. The canvas element becomes white.

Also the canvas does not react on clicks anymore so that I am not able to continue painting.
For me it seems that javascript crashed, but neither Firebug nor the firefox error-console display any errors.

  • 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-27T18:15:14+00:00Added an answer on May 27, 2026 at 6:15 pm

    I’m not sure I known what you need to do.
    I have a live demo where is canvas on which are painted rectangles and I bound a listener to click event. When you click on canvas new HTMLParagraphElement is created in place on current mouse position. Demo is available on: http://jsfiddle.net/wDpFk/

    Assume, Paragraph position is defined in css as absolute and of course the color attribute should be differently than either black or red 🙂

    Ok. Draw something on canvas

    var c = document.getElementById("c"),
        ctx = c.getContext( "2d" );
    
    ctx.fillRect( 0, 0, 100, 100 );
    ctx.fillStyle = "red";
    ctx.fillRect( 22, 25, 25, 25 );
    

    And now:

    //without jquery
    c.onclick = function( event ) {
      var e = window.event || event,
          p =document.createElement( "p" );
    
      p.innerHTML = "text";
      p.style.left = e.clientX + "px";
      p.style.top = e.clientY + "px";
      document.body.appendChild( p );
    };
    

    Or with jQuery:

     $( c ).click( function( e ) {
    
        $( "<p>text</p>" ).css({
           left: e.pageX,
           top: e.pageY
        }).appendTo( "body" );
    
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably something quite easy to resolve, however, I am having some difficulties
This is probably something quite easy to resolve, but for some reason, I can't
I want to change all headers, normally this is quite easy (and it probably
I have what I think is probably quite a simple question to answer (for
I have a tiny question, probably an easy one, but I couldn't found googling
it's late, I'm tired, and probably being quite dense.... I have written an application
I have quite a few problems, probably misunderstandings, about the new keyword with properties
i have another (probably unanswered) question about map views. I have a map view
I have what is probably a really simple, studid question but I can't find
I have a probably quite simple to solve problem. I'm trying to parse this

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.