
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10483 Articles for Web Development

3K+ Views
Use the playbackRate property sets the current playback speed of the audio/video. With that, the defaultPlaybackRate property sets the default playback speed of the audio/video. Change the playing speed of videos You can try to run the following code to change the playing speed of videos − /* play video thrice as fast */ document.querySelector('video').defaultPlaybackRate = 3.0; document.querySelector('video').play(); Play video twice as fast The following is to play the video twice as fast − /* play video twice as fast */ document.querySelector('video').playbackRate = 2;

295 Views
Use createReadStream to send the requested part to the client. The function call createReadStream() will give you a readable stream. ExampleThe following is the code −stream = fs.createReadStream(path); stream.on('open', function () { res.writeHead(206,{ "Content-Range":"bytes " + begin + "-" + end + "/" +total, "Accept-Ranges":"bytes", "Content-Length":chunksize, "Content-Type":"new/mp4" }); stream.pipe(res); });

1K+ Views
If you have a data url, you can create an image to a canvas. This can be done as shown in the following code snippet −var myImg = new Image; myImg.src = strDataURI;The drawImage() method draws an image, canvas, or video onto the canvas. The drawImage() method can also draw parts of an image, and/or increase/reduce the image size.The code given below is also appropriate with the sequence - create the image, set the onload to use the new image, and then set the src −// load image from data url Var Obj = new Image(); Obj.onload = function() { ... Read More

261 Views
h1 is a heading and not a title. Youcan gives own heading element to each sectioning element. h1 cannot be the title. It can be the heading of that particular section of the page. Each article can have its own title. defines the most important heading. The first element is considered the label for the entire document. It is perfectly fine to use as many tags as your document calls for; that is one per sectioning root or content section. Use one set of tags per sectioning root or content section. There should always be an ... Read More

2K+ Views
The fillText() method draws filled text on the canvas. If you want to break lines you can do this by splitting the text at the new lines and calling the filltext() multiple times. By doing so, you are splitting the text into lines and drawing each line separately.You can try to run the following code snippet − var c = $('#c')[0].getContext('2d'); c.font = '12px Courier'; alert(c); var str = 'first line second line...'; var a = 30; var b = 30; var lineheight = 15; var lines = str.split(''); for (var j = 0; j

300 Views
It is possible to change the textcolour depending on the average brightness of the covered pixels ofits parent's background color by using the following code snippet.var rgb = [255, 0, 0]; setInterval(display, 1000); function display() { rgb[0] = Math.round(Math.random() * 255); rgb[1] = Math.round(Math.random() * 255); rgb[2] = Math.round(Math.random() * 255); var d = Math.round(((parseInt(rgb[0]) * 299) + (parseInt(rgb[1]) * 587) + (parseInt(rgb[2]) * 114)) / 1000); // for foregound var f = (d> 125) ? 'black' : 'white'; // for background var b = 'rgb(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ')'; $('#box').css('color', f); $('#box').css('background-color', b); } DemoThe following is the CSS −#box { width: 300px; height: 300px; }

2K+ Views
As you may have seen, whenever you open a dropdown, and click anywhere else, the dropdown close. By using the below given code, the dropdown menu can be kept open after click−$('#myDropdown').on('hide.bs.dropdown', function () { return false; });Another option is to handle the clickevent −The click event can also be handled byusing the following code. The event.stopPropagation() method stopsthe bubbling of an event to parent elements. It prevents any parentevent handlers from being executed −$('#myDropdown .dropdown-menu').on({ "click":function(e) { e.stopPropagation(); } });

429 Views
Before HTML5, the file size was checked with flash but now flash is avoided in web apps. Still the file size on the client side can be checked by inserting the below given code inside an event listener.if (typeofFileReader !== "undefined") { // file[0] is file 1 var s = document.getElementById('myfile').files[0].size; }On file input change, the size will update. For that, use event listener,document.getElementById('input').onchange = function() { // file[0] is file 1 var s = document.getElementById('input').files[0].size; alert(s); }

954 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();

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