I’m currently building a HTML5 web app/Phonegap native app and I can’t seem to figure out how to save my canvas as an image with canvas.toDataURL()
. Can somebody help me out?
Here’s the code, what’s wrong with it?
//My canvas was named “canvasSignature”
JavaScript:
function putImage() { var canvas1 = document.getElementById("canvasSignature"); if (canvas1.getContext) { var ctx = canvas1.getContext("2d"); var myImage = canvas1.toDataURL("image/png"); } var imageElement = document.getElementById("MyPix"); imageElement.src = myImage; } HTML5: <div id="createPNGButton"> <button onclick="putImage()">Save as Image</button> </div>
Related Posts:
- How to clear the canvas for redrawing
- Cannot read property ‘getContext’ of null, using canvas
- getContext is not a function
- How to clear the canvas for redrawing
- How can I generate a rainbow circle using HTML5 canvas?
- Failed to load resource: the server responded with a status of 404 (Not Found)
- Failed to load resource: the server responded with a status of 404 (Not Found)
- Maximum call stack size exceeded error
- How to properly use jsPDF library
- Can I use complex HTML with Twitter Bootstrap’s Tooltip?
- Google Chrome Uncaught (in promise) DOMException while playing AUDIO
- How to make a word underline in Markdown
- ChartJS beginAtZero, min, max doesn’t work
- How do I check whether a checkbox is checked in jQuery?
- how to fix : ” TypeError: Cannot read property ‘addEventListener’ of null”…?//
- Cannot set property InnerHTML of null [duplicate]
- ReferenceError: $ is not defined
- How to fix “Cannot read property ‘addEventListener’ of null” error [duplicate]
- React.js: Set innerHTML vs dangerouslySetInnerHTML
- How do I check whether a checkbox is checked in jQuery?
- jQuery document.createElement equivalent?
- (Google Map API) Geocode was not successful for the following reason: REQUEST_DENIED
- How to make a word underline in Markdown
- Pure JavaScript equivalent of jQuery’s $.ready() – how to call a function when the page/DOM is ready for it [duplicate]
- How to play audio?
- How to play audio?
- Tallest Unicode character?
- How can I scroll to an element using jQuery?
- jQuery.click() vs onClick
- jQuery Get Selected Option From Dropdown
- Include another HTML file in a HTML file
- Check if checkbox is checked with jQuery
- Add swipe left/right to web page, but use default swipe up/down
- How to add jQuery code into HTML Page
- How can I get the data-id attribute?
- Check if checkbox is checked with jQuery
- How to resolve the C:\fakepath?
- What is the meaning of == $0 that is shown in inspect element of google chrome for the selected element [duplicate]
- Angular: mat-form-field must contain a MatFormFieldControl
- (change) vs (ngModelChange) in angular
- Bootstrap Dropdown menu is not working
- jquery SlideToggle effect in upward direction?
- Change Background color (css property) using Jquery
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- Get class name using jQuery
- Adding options to select with javascript
- JavaScript runtime error: ‘$’ is undefined
- Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser
- Set timeout for ajax (jQuery)
- How does the data-toggle attribute work? (What’s its API?)
- CSS height 100% percent not working
- JavaScript get element by name
- Use images like checkboxes
- How to read xml file contents in jQuery and display in html elements?
- HTML5 Local storage vs. Session storage
- Completely disable scrolling of webpage
- TypeError: Cannot Set property ‘onclick’ of null
- Express Render not working return error: No default engine was specified and no extension was provided
- How do I scroll to an element using JavaScript?
- Jquery swipe left or right on mobile
- Programmatically change the src of an img tag
- display variable image using cookies
- How to move an element into another element?
- character counter – backspace doesn’t reflect on characters remaining
- Open URL in same window and in same tab
- Create table with jQuery – append
- Error: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of type ‘Node’
- How to convert selected HTML to Json?
- How would I call a javascript function in html?
- How to Open New window on every Click
- Encode HTML entities in JavaScript
- “.addEventListener is not a function” why does this error occur?
- Uncaught TypeError: Cannot read property ‘top’ of undefined
- How to move all HTML element children to another parent using JavaScript?
- How can I select an element by name with jQuery?
- Full-screen iframe with a height of 100%
- Coin toss with JavaScript and HTML
- Resize image with javascript canvas (smoothly)
- How to print HTML content on click of a button, but not the page?
- jQuery disable/enable submit button
- Play an audio file using jQuery when a button is clicked
- How to move an element after another element using JS or jquery?
- Bootstrap 4 Dropdown Menu not working?
- How to use Javascript to read local text file and read line by line?
- Parse an HTML string with JS
- Why is the jquery script not working?
- Shortest way to print current year in a website
- getBoundingClientRect is not a function
- DOMException: Failed to load because no supported source was found
- document.getElementsByClassName().innerHTML always returns “undefined”
- Jquery button click() function is not working
- Make iframe automatically adjust height according to the contents without using scrollbar?
- Vue is not defined
- How do I modify the URL without reloading the page?
- Textarea Auto height
- OnChange event handler for radio button (INPUT type=”radio”) doesn’t work as one value
- Partial render in HTML/JavaScript
- Error: ENOENT: no such file or directory, stat ‘/public/main.html’ at Error (native)
- onClick to get the ID of the clicked button
- HTML text input allow only numeric input