Front End Technology Articles

Page 567 of 652

HTML 5 local Storage size limit for sub domains

Sreemaha
Sreemaha
Updated on 04-Mar-2020 682 Views

HTML5's localStorage databases are size-limited. The standard sizes are 5 or 10 MB per domain. A limit of 5 MB per origin is recommended.The following is stated −User agents should guard against sites storing data under their origin's other affiliated sites, e.g. storing up to the limit in a1.example.com,a2.example.com, a3.example.com, etc, circumventing the mainexample.com storage limit.For size limit −A mostly arbitrary limit of five megabytes per origin is suggested. Implementation feedback is welcome and will be used to update this suggestion in the future.

Read More

How can I use the HTML5 canvas element in IE?

Chandu yadav
Chandu yadav
Updated on 04-Mar-2020 356 Views

Use excanvas JavaScript library to use HTML5 canvas in Internet Explorer(IE).The excanvas library is an add-on, which will add the HTML5 canvas functionality to the old IE browsers (IE7-8).Firefox, Safari and Opera 9 support the canvas tag to allow 2D command-based drawing operations.ExplorerCanvas brings the same functionality to Internet Explorer. To use the HTML5 canvas element in IE, include the ExplorerCanvas tag in the same directory as your HTML files, and add the following code to your page in the head tag.

Read More

How to fix getImageData() error ‘The canvas has been tainted by cross-origin data’ in HTML?

George John
George John
Updated on 04-Mar-2020 2K+ Views

The crossOrigin attribute allows images that are loaded from external origins to be used in canvas like the one they were being loaded from the current origin.Using images without CORS approval tains the canvas. Once a canvas has been tainted, you can no longer pull data back out of the canvas. By loading the canvas from cross origin domain, you are tainting the canvas.You can prevent this by setting −img.crossOrigin = "Anonymous";This works if the remote server sets the header aptly −Access-Control-Allow-Origin "*"

Read More

Is it possible to style HTML5 audio tag?

varma
varma
Updated on 04-Mar-2020 4K+ Views

HTML 5 audio tags can be styled. By using the audio tag with “controls” attribute, the default browsers player is used. You can customize by not using the browsers controls. By removing the controls attribute, you can hide the built in browser user’s interface −    Play    Pause    Vol+    Vol- You can also add CSS classes to each one of the elements and style them accordingly.

Read More

How to save HTML Canvas as an Image with canvas.toDataURL()?

radhakrishna
radhakrishna
Updated on 04-Mar-2020 1K+ Views

Use toDataURL() method to get the image data URL of the canvas. It converts the drawing (canvas) into a64 bit encoded PNG URL.ExampleYou can try to run the following code to save the canvas as an image −                                  var canvas = document.getElementById('newCanvas');          var ctx = canvas.getContext('2d');          // draw any shape          ctx.beginPath();          ctx.moveTo(120, 50);          ctx.bezierCurveTo(130,100, 130, 250, 330, 150);          ctx.bezierCurveTo(350,180, 320, 180, 240, 150);          ctx.bezierCurveTo(320,150, 420, 120, 390, 100);          ctx.bezierCurveTo(130,40, 370, 30, 240, 50);          ctx.bezierCurveTo(220,7, 350, 20, 150, 50);          ctx.bezierCurveTo(250,5, 150, 20, 170, 80);          ctx.closePath();          ctx.lineWidth = 3;          ctx.fillStyle ='#F1F1F1';          ctx.fill();          ctx.stroke();          var dataURL =canvas.toDataURL();          

Read More

How do I add a simple onClick event handler to an HTML5 canvas element?

Ankith Reddy
Ankith Reddy
Updated on 04-Mar-2020 6K+ Views

The elements that are drawn in canvas element have no representation. Their only representation is the pixels they use and their color. Drawing to a canvas element means drawing a bitmap in immediate mode. To get a click event on a canvas element (shape), you need to capture click events on the canvas HTML element and determine which element was clicked. This requires storing the element’s width and height.To add a click event to your canvas element, use the below-given codecanvas.addEventListener('click', function() { }, false);ExampleTo determine what element was clicked, use the following code snippet −var e = document.getElementById('myCanvas'),   ...

Read More

How to center canvas in HTML5?

vanithasree
vanithasree
Updated on 03-Mar-2020 12K+ Views

To center canvas in HTML 5, include the canvas tag in div tag. Then we can center align the div tag. By doing so, the canvas is also center aligned.Example.                    This is my canvas          

Read More

HTML5 inline video on iPhone vs iPad/Browser

Chandu yadav
Chandu yadav
Updated on 03-Mar-2020 547 Views

The allowsInlineMediaPlayback  property of a UIWebView) enables/ disables in line media playback in the iOS web browser for a native app. By default, on iPhone this is set to NO, but on iPad its set to YES. Hence, the native video player takes over the screen, thus obstructing us from playing other dynamic content simultaneously with the video Adjust this behaviour in HTML as follows − iOS10+ In iOS 10+, Apple has now enabled the attribute playsinline in all the web browsers on iOS 10. Now, play around with this easily −

Read More

How to copy the content of one HTML5 Canvas to another Canvas locally?

Chandu yadav
Chandu yadav
Updated on 03-Mar-2020 3K+ Views

The drawImage() method is used to draw image, canvas and videos on canvas. It can also draw part of image and increase or decrease the image size.ExampleLet us see an example −//context grabbed from your destination canvas ctx = destinationCanvas.getContext('2d'); //drawImage() called passing the source canvas directly dCtx.drawImage(sourceCanvas, 0, 0);In this code, firstly the image is copied from the source canvas. The sourceCanvas can be a HTMLImageElement, HTMLVideoElement, or a HTMLCanvasElement. A canvas drawing context cannot be used as a source. If a canvas drawing context is your source canvas then there is a reference to the original canvas ...

Read More

Execute a script when a mouse button is pressed down on an element in HTML?

Vrundesha Joshi
Vrundesha Joshi
Updated on 03-Mar-2020 393 Views

Use the onmousedown attribute to in HTML to execute a script when a mouse button is pressed down on an element.ExampleYou can try to run the following code to implement onmousedown attribute −                    This is demo heading.             Click above and then release.                function mouseDown() {             document.getElementById("myid").style.color = "yellow";          }          function mouseUp() {             document.getElementById("myid").style.color = "blue";          }          

Read More
Showing 5661–5670 of 6,517 articles
« Prev 1 565 566 567 568 569 652 Next »
Advertisements