Found 598 Articles for Front End Scripts

Full page drag and drop files website with HTML

Lakshmi Srinivas
Updated on 28-Jan-2020 10:18:14

417 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);

Getting Safari to recognize
HTML 5

karthikeya Boyini
Updated on 28-Jan-2020 10:19:15

132 Views

To make a element to be recognized by Safari:main {    display: block;    width: 800px;    height: 800px;    background-color: #0C0; }You need to focus on:main {    display: block; }

HTML5 meta name = “viewport” doesn't work as expected

Anvi Jain
Updated on 28-Jan-2020 10:23:26

777 Views

To solve the issue for HTML5 meta viewport, you can any of the following fix:You can also try this:Let us say you have a site width of 100px, then it won’t display the whole page, withinitial-scale = 1

How to send a file and parameters within the same XMLHttpRequest

Jennifer Nicholas
Updated on 28-Jan-2020 10:34:09

465 Views

To send a file and parameters within the same XMLHttpRequest:var myForm = new FormData(); myForm.append('param1', 'demo'); myForm.append('param2', 6767); myForm.append('myDir', 'public-data'); myForm.append('demofile', file); xhr.send(myForm);

Enhance real-time performance on HTML5 canvas effects

Samual Sam
Updated on 28-Jan-2020 10:33:37

539 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

HTML5 drawImage() method to draw image onto the canvas

Rishi Rathor
Updated on 28-Jan-2020 10:23:53

338 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.');             }          }                        

Unable to take a photo from webcam using HTML5 and on the first page load

Lakshmi Srinivas
Updated on 28-Jan-2020 10:32:55

254 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);

Cross origin HTML

Samual Sam
Updated on 28-Jan-2020 10:21:47

184 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.

HTML5 audio control stop button

Lakshmi Srinivas
Updated on 28-Jan-2020 10:20:06

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; });

HTML5 validity of nested tables

Nishtha Thakur
Updated on 28-Jan-2020 10:22:50

174 Views

The validator considers the following table as valid:                 Example                                                                                                                                                My                            Table                                                                                                                

Advertisements