Javascript Articles

Page 512 of 534

toDataURL throw Uncaught Security exception in HTML

Samual Sam
Samual Sam
Updated on 29-Jan-2020 180 Views

To solve the Uncaught Security Exception, you need to add the crossorigin attribute: function getBase64() {    var myImg = document.getElementById("myid");    var c = document.createElement("canvas");    c.width = myImg.width;    c.height = myImg.width;    var context = c.getContext("2d");    context.drawImage(img, 0, 0);    var dataURL = c.toDataURL("image/png");    alert(dataURL.replace(/^data:image\/(png|jpg);base64,/, "")); } getBase64();

Read More

How to send a file and parameters within the same XMLHttpRequest

Jennifer Nicholas
Jennifer Nicholas
Updated on 28-Jan-2020 513 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);

Read More

Enhance real-time performance on HTML5 canvas effects

Samual Sam
Samual Sam
Updated on 28-Jan-2020 582 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

Read More

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

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 28-Jan-2020 281 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);

Read More

HTML5 meta name = "viewport" doesn't work as expected

Anvi Jain
Anvi Jain
Updated on 28-Jan-2020 817 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

Read More

HTML5 validity of nested tables

Nishtha Thakur
Nishtha Thakur
Updated on 28-Jan-2020 206 Views

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

Read More

Cross origin HTML does not load in Google Chrome

Samual Sam
Samual Sam
Updated on 28-Jan-2020 235 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.

Read More

HTML5 audio control stop button

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 28-Jan-2020 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; });

Read More

Getting Safari to recognize HTML 5

karthikeya Boyini
karthikeya Boyini
Updated on 28-Jan-2020 176 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; }

Read More

Full page drag and drop files website with HTML

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 28-Jan-2020 470 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);

Read More
Showing 5111–5120 of 5,339 articles
« Prev 1 510 511 512 513 514 534 Next »
Advertisements