Samual Sam has Published 2310 Articles

How to play HTML5 Audio Randomly

Samual Sam

Samual Sam

Updated on 29-Jan-2020 10:14:38

972 Views

To play randomly, add the songs like this:init ([    'http://demo.com/songs/song1.mp3,    'http://demo.com/songs/song2.mp3,    'http://demo.com/songs/song3.mp3 ]);Use the following to play randomly using Math.random:function displayRandom() {    var audio = Math.floor(Math.random() * (collection.length));    audio = collection[audio];    audio.play();    setTimeout(loop, audio.duration*1000); }Read More

Making an image scale mouse over on HTM5

Samual Sam

Samual Sam

Updated on 29-Jan-2020 08:19:37

332 Views

To make an image scale on mouse over, use Vanilla JavaScript library.On mouse move, set it like the following:function move(e) {    var pos = getMousePos(myCanvas, e);    context.drawImage(img, -pos.x, -pos.y, img.width, img.height); }For canvas://add event listener we need myCanvas.addEventListener('mouseout', display, false); myCanvas.addEventListener('mousemove', move, false);function display() {    context.drawImage(img, 0, ... Read More

How to load an HTML file into the canvas?

Samual Sam

Samual Sam

Updated on 29-Jan-2020 08:12:55

772 Views

For this, you can use the SVG elements. Let us see an example:           DEMO          

An empty box is displayed instead of the rupee symbol in HTML

Samual Sam

Samual Sam

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

234 Views

The rupee symbol is the following and not every browser supports it:₹To make it visible on your web page: You can use the following as well:₹

HTML5 Microdata Attributes

Samual Sam

Samual Sam

Updated on 29-Jan-2020 07:25:23

185 Views

Microdata introduces five global attributes that would be available for any element to use and give context for machines about your data.AttributeDescriptionItemscopeThis is used to create an item. The itemscope attribute is a boolean attribute that tells that there is Microdata on this page, and this is where it starts.Itemtype This ... Read More

Draw Lines with easelJS using Ticker in HTML

Samual Sam

Samual Sam

Updated on 29-Jan-2020 06:39:08

353 Views

EaseLJS is a JavaScript library to make the HTML5 Canvas element easy. Use it for creating games, graphics, etc.To draw lines using Ticker method in HTML with easeLJS:var myLine = new createjs.Shape(); myLine.graphics.setStrokeStyle(4); myLine.graphics.beginStroke(color); myLine.graphics.moveTo(startX, startY); startY++; myLine.graphics.lineTo(startX, startY); myLine.graphics.endStroke();Read More

Blank PNG image is shown with toBase64Image() function

Samual Sam

Samual Sam

Updated on 29-Jan-2020 06:35:13

242 Views

If a blank image is shown with the toBase64Image() function, you need to use the following to work on it correctly:animation: {    duration: 2000,    onComplete: function (animation) {       this.toBase64Image();    } }With that, you can also use another fix. Call save64Img(myChart.toBase64Image()) over an additional callback ... Read More

What is the most efficient way of assigning all my HTML5 video sources as trusted without having to loop over all of them

Samual Sam

Samual Sam

Updated on 29-Jan-2020 06:28:30

75 Views

Add some config to assign trust to your videos in HTML5:app.config(function($sceDelegateProvider) {    $sceDelegateProvider.resourceUrlWhitelist([    // allowing same origin resource loads    'self',    // allowing loading from our assets domain    'http://media.w3.org/**']); });

How to detect the browser's format for HTML input type date

Samual Sam

Samual Sam

Updated on 29-Jan-2020 06:26:09

391 Views

An input.the valueAsDate method returns a Date object reflecting the input's current value. The displayed value follows the same format. To make it work:new Date().toISOString().substr( 0, 10 ); new Date().toLocaleDateString(); input.valueAsDate; input.valueAsDate.toLocaleDateString(); new Date( input.valueAsDate ); new Date( input.valueAsDate ).toISOString().substr( 0, 10 );

toDataURL throw Uncaught Security exception in HTML

Samual Sam

Samual Sam

Updated on 29-Jan-2020 06:24:50

143 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 ... Read More

Advertisements