Found 10483 Articles for Web Development

Stop Web Workers in HTML5

Nishtha Thakur
Updated on 28-Jan-2020 07:46:34

1K+ Views

Web Workers allow for long-running scripts that are not interrupted by scripts that respond to clicks or other user interactions and allows long tasks to be executed without yielding to keep the page responsive.Web Workers don't stop by themselves but the page that started them can stop them by calling terminate() method.worker.terminate();A terminated Web Worker will no longer respond to messages or perform any additional computations. You cannot restart a worker; instead, you can create a new worker using the same URL.

Is HTML5 canvas and image on polygon possible?

George John
Updated on 25-Jun-2020 08:15:15

426 Views

Yes, it is possible. Create a pattern using the image, and then set the pattern to fillStyle.Here, obj is our image object −var context = canvas.getContext("2d"); var pattern = context.createPattern(obj, "repeat"); context.fillStyle = pattern;You need to manipulate the image to fit an arbitrary polygon −context.save(); context.setTransform(m11, m12, m21, m22, dx, dy); context.drawImage(obj); context.restore();

Image button with HTML5

Yaswanth Varma
Updated on 16-Dec-2022 10:49:22

21K+ Views

In the following article, we are going to learn about image buttons with HTML5. In this task we are making the image to act as a button, When the user clicks the button, the form is sent to the server. Let's look into it. What is image button Image buttons are created by placing tag inside the tag creates a clickable HTML button with an image embedded in it. tag By using the tag we can include an image on a HTML page. Images are not actually embedded in the webpages; instead, they are connected to ... Read More

Detect folders in Safari with HTML5

Smita Kapse
Updated on 25-Jun-2020 08:02:02

144 Views

You can try to run the following code to detect folders in Safari −Array.prototype.forEach.call(e.dataTransfer.files, function (file) {    var r = new FileReader();    r.onload = function (event) {       addFile(file);    };    r.onerror = function (event) {       alert("Uploading folders isn't supported in Safari browser!");    }    r.readAsDataURL(file); });

Creating content with HTML5 Canvas much more complicated than authoring with Flash

Anvi Jain
Updated on 28-Jan-2020 07:44:40

152 Views

Flash provides amazing GUI and lots of visual features for animations. It allows the user build everything inside a particular platform without a full integration into the browser wrapped inside the browser with the main scopes that are multimedia and other kinds of animation.HTML5 element gives you an easy and powerful way to draw graphics using JavaScript. It can be used to draw graphs, make photo compositions or do simple (and not so simple) animations.Here is a simple element which has only two specific attributes width and height plus all the core HTML5 attributes like id, name, and ... Read More

HTML5 Canvas Degree Symbol

Arjun Thakur
Updated on 05-Apr-2022 12:35:42

452 Views

For HTML5 Canvas degree symbol, try to run the following code −                          body {             margin:5em;             background:#eee;             text-align:center          }          canvas {             background:#fff;             border:2px solid #ccc;             display:block;             margin:3em auto          }                              var c = document.getElementsByTagName('canvas')[0];          c.width = c.height = 300;          var context = c.getContext('2d');          context.font = "20px sans-serif";          context.fillText("212° Fahrenheit", 100, 100);          

How to stop dragend's default behavior in drag and drop?

Ankith Reddy
Updated on 25-Jun-2020 08:04:08

213 Views

To stop dragend’s default behavior, you need to detect if the mouse is over the drop target where you want to drop.This is what you should do only if you are hovering over my list − listContainer.insertBefore(source, myNode);Use jQuery −if ($(mylist).parent().find(":hover")) {    listContainer.insertBefore(source, myNode); }

Proper use of flex properties when nesting flex containers

AmitDiwan
Updated on 06-Dec-2022 10:55:50

1K+ Views

A flex container is always the parent and a flex item is always the child. The scope of a flex formatting context is limited to a parent/child relationship. Descendants of a flex container beyond the children are not part of flex layout and will not accept flex properties. There are certain flex properties that apply only to flex containers − justify-content, flex-wrap andflex-direction There are certain flex properties that apply only to flex items” align-self flex-grow flex Always apply display: flex or display: inline-flex to a parent in order to apply flex properties to the child. Let ... Read More

HTML5 Canvas Font Size Based on Canvas Size

George John
Updated on 25-Jun-2020 08:05:40

837 Views

To scale fonts, let us see an example.Canvas: 800px Font Size: 60pxYou need to use the following code for our example to scale font size based on canvas −var fontBase = 800; var fontSize = 60; function getFont() {    var ratio = fontSize / fontBase;    var cSize = canvas.width * ratio;    return (cSize |0) + 'px sans-serif'; }

HTML5 Canvas fit to window

Riya Kumari
Updated on 12-Oct-2022 14:29:12

12K+ Views

When you view a webpage containing canvas in different screens like that of mobile, pc, desktop or tablet, the size of the screen changes each time. So, it is necessary that the canvas resizes itself according to the screen for better user experience. In this article, we will learn how to resize an HTML5 canvas to fit the window. Let us first understand more about HTML5. HTML5 HTML (Hyper Text Markup Language) is a standard markup language for web pages. Using HTML, you can create your own website. HTML5 is the updated version of HTML with advanced technology used in ... Read More

Advertisements