Javascript Articles

Page 507 of 534

Working with tag in HTML5

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 29-Jan-2020 314 Views

You can try to run the following code to learn how to work with the tag in HTML5:                    #svgelem{             position: relative;             left: 50%;             -webkit-transform: translateX(-40%);             -ms-transform: translateX(-40%);             transform: translateX(-40%);          }             SVG                     HTML5 SVG Star                      

Read More

How to draw large font on HTML5 Canvas?

karthikeya Boyini
karthikeya Boyini
Updated on 29-Jan-2020 283 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);

Read More

How to display rupee symbol in HTML

Govinda Sai
Govinda Sai
Updated on 29-Jan-2020 2K+ 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:₹

Read More

Composition attribute in HTML5 Canvas?

Jennifer Nicholas
Jennifer Nicholas
Updated on 29-Jan-2020 287 Views

HTML5 canvas provides compositing attribute globalCompositeOperation that affect all the drawing operations. var compositeTypes = [ 'source-over','source-in','source-out','source-atop', 'destination-over','destination-in','destination-out', 'destination-atop','lighter','darker','copy','xor' ]; function drawShape(){ for (i = 0; i < compositeTypes.length; i++){ var label = document.createTextNode(compositeTypes[i]); document.getElementById('lab'+i).appendChild(label); var ctx = document.getElementById('tut'+i).getContext('2d'); // draw rectangle ctx.fillStyle = "#FF3366"; ctx.fillRect(15,15,70,70); // set composite property ctx.globalCompositeOperation = compositeTypes[i]; // draw circle ctx.fillStyle = "#0066FF"; ctx.beginPath(); ctx.arc(75,75,35,0,Math.PI*2,true); ctx.fill(); } }

Read More

Blending two images with HTML5 canvas

karthikeya Boyini
karthikeya Boyini
Updated on 29-Jan-2020 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");       var ctx = canvas.getContext("2d");       // width and height       var w = img1.width;       var h = img1.height;       myCanvas.width = w;       myCanvas.height = h;       var pixels = 4 ...

Read More

HTML5 IndexedDB Example

Sravani S
Sravani S
Updated on 29-Jan-2020 269 Views

The following function is an example of IndexedDB to add data:function add() {    var request = db.transaction(["employee"], "readwrite")    .objectStore("employee")    .add({ id: "001", name: "Amit", age: 28, email: "demo1@example.com" });    request.onsuccess = function(event) {       alert("Amit has been added to your database.");    };    request.onerror = function(event) {       alert("Unable to add data\rAmit is already exist in your database! ");    } }Above, we added the following details in the database:const employeeData = [    { id: "001", name: "Amit", age: 28, email: "demo1@example.com" }, ];

Read More

Example of createSignalingChannel() in HTML5

Vrundesha Joshi
Vrundesha Joshi
Updated on 29-Jan-2020 182 Views

Web RTC required peer-to-peer communication between browsers. This mechanism required signalling, network information, session control and media information. Web developers can choose different mechanism to communicate between the browsers such as SIP or XMPP or any two way communications. An example of createSignalingChannel():var signalingChannel = createSignalingChannel(); var pc; var configuration = ...; // run start(true) to initiate a call function start(isCaller) { pc = new RTCPeerConnection(configuration); // send any ice candidates to the other peer pc.onicecandidate = function (evt) { signalingChannel.send(JSON.stringify({ "candidate": evt.candidate })); ...

Read More

How to detect a particular feature through JavaScript with HTML

Nishtha Thakur
Nishtha Thakur
Updated on 29-Jan-2020 218 Views

Use Modernizr in HTML to detect a feature like audio through JavaScript:if (Modernizr.audio) {    /* properties for browsers that    support audio */ } else{    /* properties for browsers that    does not support audio */ }

Read More

How to check web browser support in HTML5

Smita Kapse
Smita Kapse
Updated on 29-Jan-2020 297 Views

You can try to run the following code to detect a web worker feature available in a web browser:           Big for loop                      function myFunction(){             if (Modernizr.webworkers) {                alert("Congratulations!! You have web workers support." );             } else{                alert("Sorry!! You do not have web workers support." );             }          }                     Click me     The following is the result:

Read More

Log error to console with Web Workers in HTML5

karthikeya Boyini
karthikeya Boyini
Updated on 29-Jan-2020 709 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 = new Worker('bigLoop.js');          worker.onmessage = function (event) {             alert("Completed " + event.data + "iterations" );          };          worker.onerror = function (event) {             console.log(event.message, event);          };          function sayHello(){             alert("Hello sir...." );          }                        

Read More
Showing 5061–5070 of 5,339 articles
« Prev 1 505 506 507 508 509 534 Next »
Advertisements