Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Front End Scripts Articles - Page 32 of 60
430 Views
For full page drag and drop files, try the following code:var myDrop = document.getElementById('dropZone'); function displayDropZone() { myDrop.style.visibility = "visible"; } function hideDropZone() { myDrop.style.visibility = "hidden"; } function allowDrag(ev) { if (true) { ev.dataTransfer.dropEffect = 'copy'; ev.preventDefault(); } } function handleDrop(ev) { ev.preventDefault(); hideDropZone(); alert('This is Drop!'); } window.addEventListener('dragenter', function(ev) { displayDropZone(); }); myDrop.addEventListener('dragenter', allowDrag); myDrop.addEventListener('dragover', allowDrag); myDrop.addEventListener('dragleave', function(e) { hideDropZone(); }); myDrop.addEventListener('drop', handleDrop);
548 Views
To enhance HTML5 canvas performance:Image smoothing should be disabledRender in half resolutionUse drawImage() to update main canvas You need to use integer coordinates and sizesUsage of requestAnimationFrame() You need to use while loops as often as you can
348 Views
To draw image onto the canvas, use the HTML5 drawImage() method: function drawShape(){ // get the canvas element using the DOM var canvas = document.getElementById('mycanvas'); // Make sure we don't execute when canvas isn't supported if (canvas.getContext){ // use getContext to use the canvas for drawing var ctx = canvas.getContext('2d'); // Draw shapes var img = new Image(); img.src = '/images/backdrop.jpg'; img.onload = function(){ ctx.drawImage(img,0,0); ctx.beginPath(); ctx.moveTo(30,96); ctx.lineTo(70,66); ctx.lineTo(103,76); ctx.lineTo(170,15); ctx.stroke(); } } else { alert('You need Safari or Firefox 1.5+ to see this demo.'); } }
257 Views
You need to try the following to take photo from webcam using HTML5:Declare variablesvar streaming = false, video = document.querySelector('#video'), canvas = document.querySelector('#canvas'), photo = document.querySelector('#photo'), startbutton = document.querySelector('#startbutton'), width = 320, height = 0;Using getUserMedianavigator.getMedia = ( navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
198 Views
To solve the loading issues in the element, you need to set cross-origin to “anonymous”:You can also try another fix also.This can be due to missing of Access-Control-Allow-Headers response header with the list of HTTP headers that match the list passed in Access-Control-Request-Headers request header.
1K+ Views
Try the following code to add a stop button to your audio in HTML5:function displayStopBtn() { var myPlayer = document.getElementsByTagName('audio')[0]; myPlayer.pause(); myPlayer.currentTime = 0; }You can also include jQuery:$("#stopButton").click(function () { audio.pause(); audio.currentTime = 0; });



