Karthikeya Boyini has Published 2193 Articles

Is their a cross-origin attribute in HTML5?

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 10:23:18

218 Views

Yes, the official specification states cross-origin attribute as:The crossorigin attribute is a CORS settings attribute. Its purpose is to allow images from third-party sites that allow cross-origin access to be used with canvas.You can use it to solve JavaScript errors like to log js errors:if (securityOrigin()->canRequest(targetUrl)) {    msg = ... Read More

How to draw large font on HTML5 Canvas?

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 10:17:56

248 Views

To draw large font properly in HTML5 Canvas, you can try to run the following code:var myCanvas = document.getElementById("myCanvas"); var context = c.getContext("2d"); context.font = '180pt Georgia'; context.strokeStyle = "#FF0000"; context.fillStyle = "#FFFFFF "; context.lineWidth = 34; context.fillText("Demo!",0,200); context.strokeText("Demo!",0,200);

Blending two images with HTML5 canvas

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 10:15:17

2K+ Views

To blend, you need to perform blending of two images in proportion 50-50.Let us see how: Blended image    window.onload = function () {       var myImg1 = document.getElementById('myImg1');       var myImg2 = document.getElementById('myImg2');       var myCanvas = document.getElementById("canvas"); ... Read More

Creating custom attributes with HTML5

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 08:38:59

362 Views

A new feature introduced in HTML 5 is the addition of custom data attributes.A custom data attribute starts with data- and would be named based on your requirement.    ... The above will be perfectly valid HTML5 with two custom attributes called data-subject and data-level. You would be able to ... Read More

Log error to console with Web Workers in HTML5

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 08:34:25

672 Views

Here is an example of an error handling function in a Web Worker JavaScript file that logs errors to the console.ExampleWith error handling code, above example would become like the following:           Big for loop                var worker ... Read More

Resize image before submitting the form HTML5

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 08:22:08

322 Views

To resize the image before submitting the form, you need to use the drawImage() method.Scale the original image and draws the scaled version on the canvas at [0, 0]context.drawImage( img, 0, 0, img.width, img.height, 0, 0, myWidth, UseHeight );Above, we saw the following:Here, var myWidth = Math.floor( img.width * Scale ... Read More

XMLHttpRequest for Video Tag?

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 08:14:09

519 Views

The HTML5 file Blob.slice() method is useful for creating a Blob object containing the data. This data is in the specified range of bytes of the source Blob. It uses XMLHttpRequest as in the below example.Let us see an example to send and receive binary data using slice(). This example ... Read More

How to keep the image at the back of the HTML5 canvas when moving elements with fabric.js?

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 08:11:26

351 Views

To keep the image at the back of the canvas, when move elements, you need to pass:preserveObjectStackingAnd the following would work and the image is not visible in the background:window.canvas = new fabric.Canvas('c', { preserveObjectStacking:true });Now, on moving the shape will appear over the image.

How can I handle Server-Sent Events in HTML5?

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 07:04:00

169 Views

To handle Server-Sent Events in HTML5, you can try to run the following code:                    document.getElementsByTagName("eventsource")[0].addEventListener("server-time", eventHandler, false);          function eventHandler(event)          {             // Alert time sent by the server             document.querySelector('#ticker').innerHTML = event.data;          }                                                    [TIME]          

canvas.style.display = “block” not working in HTML5

karthikeya Boyini

karthikeya Boyini

Updated on 29-Jan-2020 06:40:33

268 Views

Change the setTimeout() to use a function reference. It works as the function available at the time the reference.The reference will be transferred to the timeout event callback rather than a string reference:window.setTimeout(startNow, 2000);Set it like the following:setTimeout(startNow, 1000); function startNow () {    alert(‘Working correctly!'); }Read More

Advertisements