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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:54:34+00:00 2026-05-25T01:54:34+00:00

I’ve got here some javascript code, that implements a signature pad. It works fine

  • 0

I’ve got here some javascript code, that implements a signature pad. It works fine on google chrome but it doesn’t work on firefox. Here is the code:

<html>
   <head>
      <title>Signature Pad</title>
     <script src="lib/jquery-1.6.2.min.js" type="text/javascript"></script>
      <script type="text/javascript">
      //fires when document is loaded and DOM is ready.
      $(document).ready(function() {

  var context, canvas, drawLine, mouseIsPressed, x, y, prevX, prevY, borderWidth;
         canvas = document.getElementById('canvas'); //retrieve canvas from dom by id that we have assigned
         context = canvas.getContext('2d'); //retrieve context
         borderWidth = 5; //let border width will be 5 pixel
         canvas.style.border = borderWidth + " px solid #00F000"; // 5 pixel width solid green border
         drawLine = function(x1, y1, x2, y2)
         {
            context.beginPath(); //create a path
            context.moveTo(x1 - borderWidth, y1 - borderWidth); //move to
            context.lineTo(x2 - borderWidth, y2 - borderWidth); //draw a line
            context.stroke(); // filled with "ink"
            context.closePath(); //close path
         };
         canvas.onmousedown = function(evt)
         {
            mouseIsPressed = true; //save that mouse is pressed
            drawLine(evt.offsetX, evt.offsetY, evt.offsetX + 1, evt.offsetY + + 1) //draw short line that looks like a dot
         };
         canvas.onmouseup = function(evt)
         {
            mouseIsPressed = false; //save that mouse is released
         };
         canvas.onmousemove = function(evt)
         {
            x = evt.offsetX; 
            y = evt.offsetY; //get current X and Y
            if(mouseIsPressed)
            {
               drawLine(prevX, prevY, x, y);  //draw a line on canvas from previous to current point.
            }
            prevX = x; prevY = y; //save previous x and y in both case, weather mouse is pressed or not
         };
      });



      </script>
   <head>
   <body>
      <canvas width="300" height="200" id="canvas"></canvas>
   </body>
</html>

Firefox does support HTML5 Canvas as far as i know. And I do have Version 6. I also checked if javascript was disabled, but that wasn’t the problem. I have no idea why it doesn’t work.

  • 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-25T01:54:35+00:00Added an answer on May 25, 2026 at 1:54 am

    Three things you need to change:
    1. borderWidth + ” px solid #00F000″; The border won’t show in Firefox. Remove the empty before px.
    2. change offsetX to clientX
    3. change offsetY to clientY

    The final code:

    <html> 
       <head> 
          <title>Signature Pad</title> 
         <script src="jquery-1.6.2.min.js" type="text/javascript"></script> 
          <script type="text/javascript"> 
          //fires when document is loaded and DOM is ready. 
          $(document).ready(function() { 
    
      var context, canvas, drawLine, mouseIsPressed, x, y, prevX, prevY, borderWidth; 
             canvas = document.getElementById('canvas'); //retrieve canvas from dom by id that we have assigned 
             context = canvas.getContext('2d'); //retrieve context 
             borderWidth = 5; //let border width will be 5 pixel 
             canvas.style.border = borderWidth + "px solid #00F000"; // 5 pixel width solid green border 
    
             drawLine = function(x1, y1, x2, y2) 
             { 
                context.beginPath(); //create a path 
                context.moveTo(x1 - borderWidth, y1 - borderWidth); //move to 
                context.lineTo(x2 - borderWidth, y2 - borderWidth); //draw a line 
                context.stroke(); // filled with "ink" 
                context.closePath(); //close path 
             }; 
             canvas.onmousedown = function(evt) 
             { 
                mouseIsPressed = true; //save that mouse is pressed 
                drawLine(evt.clientX, evt.clientY, evt.clientX + 1, evt.clientY + + 1) //draw short line that looks like a dot 
             }; 
             canvas.onmouseup = function(evt) 
             { 
                mouseIsPressed = false; //save that mouse is released 
             }; 
             canvas.onmousemove = function(evt) 
             { 
                x = evt.clientX;  
                y = evt.clientY; //get current X and Y 
                if(mouseIsPressed) 
                { 
                   drawLine(prevX, prevY, x, y);  //draw a line on canvas from previous to current point. 
                } 
                prevX = x; prevY = y; //save previous x and y in both case, weather mouse is pressed or not 
             }; 
          }); 
    
          </script> 
       <head> 
       <body> 
          <canvas width="300" height="200" id="canvas" >Not support</canvas> 
       </body> 
    </html> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a text area in my form which accepts all possible characters from
I am writing an app with both english and french support. The app requests
I'm parsing an XML file, the creators of it stuck in a bunch social
I am using Paperclip to handle profile photo uploads in my app. They upload

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.