Found 444 Articles for Programming Scripts

How to save DIV as Image with HTM5 canvas to image with the extension?

Samual Sam
Updated on 24-Jun-2020 13:57:04

6K+ Views

DIV content can be saved as an image with the help of html2canvas() function in JavaScript. DIV tag defines a section in HTML document.Example      Welcome This shows the division area named cpimg.The html2canvas() function save div as an image with the following code −html2canvas(document.querySelector(“#cpimg”)).then(canvas  {         document.body.appendChild(canvas)  });It saves the referred div section “cpimg” into the image.

How to save canvas data to file in HTML5?

George John
Updated on 24-Jun-2020 13:55:49

2K+ Views

A Canvas is just a rectangular area on the HTML page. We can draw graphics in this rectangular area (Canvas) with the help of JavaScript. Canvas can be created in HTML5 as −                                 This creates an empty canvas with name canvas1 with width=200 and height=100. To draw graphics in it, we use JavaScript −var canvas = document.getElementById("Canvas1");  var ctx1 = canvas.getContext("2d"); ctx1.moveTo(0, 0); ctx1.lineTo(300, 200);  ctx1.stroke(); // This method actually draw graphics as per context object             To save this graphic, we need ... Read More

How to replace default meta tag from “layout” with customizing meta tags in “view” with HTML?

usharani
Updated on 24-Jun-2020 13:57:50

232 Views

Meta tags are used to store data about HTML documents such as who wrote it and the description of the document.The best solution is to define default tags in the application and overwrite default parameters in view. We can do so in PHP.Making changes in config file first −

Does HTML5 allow you to interact with local client files from within a browser?

varun
Updated on 24-Jun-2020 14:00:39

339 Views

HTML5 allows us to interact with local client files (local client files are the files that are locally stored in the user’s computer). This is possible because HTML5 provides powerful APIs (Application Programming Interfaces) which are the interfaces with the help of which binary data and user’s local file system can be accessed. With the help of these file APIs, web applications can read files, file directory, can drag and drop from desktop to browser.The following are the APIs that are used to access local client files −File System APIFile APIFile Writer APIThe following are some examples −With the help ... Read More

HTML file input control with capture and accept attributes is not working correctly

Lakshmi Srinivas
Updated on 24-Jan-2020 11:18:21

568 Views

Use the accept attribute to set the types of files that the server accepts in HTML. Use the attribute only with .ExampleYou can try to run the following code to work with the accept attribute:              File Upload Box                                             The capture attribute is a boolean attribute that, if specified, indicates that the capture of media directly from the device...is preferred.The capture attribute is NOT used to include the camera option in the dialog but to indicate that direct capture from the webcam is preferred.  The "correct" code is given below

Generating sound on the fly with JavaScript/ HTML5

Prabhas
Updated on 24-Jun-2020 14:01:11

368 Views

The Web Audio API is used to control audio, which allows you to choose audio sources. You can also add effects; create audio visualizations, panning, etc.ExampleYou can try to run the following code snippet to generate sound −// use one context per document. Here we are creating one context for one document. You can create for other documents also var context = new (window.AudioContext || window.webkitAudioContext)(); // oscillator var os = context.createOscillator();   os.type = 'sine'; // sine is the default. So you can also use square, saw tooth, triangle os.frequency.value = 500; // setting the frequency Hz os.connect(context.destination); ... Read More

How can I add video to site background in HTML 5?

Chandu yadav
Updated on 24-Jun-2020 13:58:52

420 Views

Add a button to play or pause the video. Then we have styled the video to a hundred percentage height and width so that it covers the entire background.The following is the code snippet to set video as a site background in HTML5.        Your browser does not support HTML5 video. The following is to pause the video −function display() {    if (video.paused) {       video.play();       btn.innerHTML = "Pause the video!";    } else {       video.pause();       btn.innerHTML = "Play";    } }

Converting video to HTML5 ogg / ogv and mpg4

karthikeya Boyini
Updated on 24-Jun-2020 13:40:14

376 Views

To convert video to ogg or mpg4, you need to use third-party software like Free HTML5 Video Player And ConverterAfter that, launch it and select input video files. Add files in any of the following formats −*.avi; *.ivf; *.div; *.divx; *.mpg; *.mpeg; *.mpe; *.mp4; *.m4v; *.webm; *.wmv; *.asf; *.mov; *.qt; *.mts; *.m2t; *.m2ts; *.mod; *.tod; *.vro; *.dat; *.3gp2; *.3gpp; *.3gp; *.3g2; *.dvr-ms; *.flv; *.f4v; *.amv; *.rm; *.rmm; *.rv; *.rmvb; *.ogv; *.mkv; *.ts.Now select the output location, click the “Browse...” button, and choose the location where the video would be saved.Select Presets, which are pre-configured. Select a player theme and click ... Read More

HTML 5 video or audio playlist

Giri Raju
Updated on 24-Jun-2020 13:41:09

709 Views

Use HTML with JavaScript to add playlist. The onended event fires when the audio/video has reached the end. You can add messages like “Thank you for watching”, “Stay tuned!”, etcExampleYou can try to run the following code to implement the onended attribute −                              Your browser does not support the video element.                      function display() {             alert ("Thank you for watching! Stay tuned!");          }           You could load the next clip in the onended event like in the below-given code    var next = "path/of/next/video.mp4";    var video = document.getElementById('video');    video.onended = function(){    video.src = next; }

How to draw grid using HTML5 and canvas or SVG?

Arjun Thakur
Updated on 24-Jun-2020 13:43:08

615 Views

In the below given example, we have first defined the width and height of the grid. Then we are defining the size of canvas and drawn gird into a canvas.//we are setting the grid width and height var grid_w = 200; var grid_h = 200; //we are setting padding around grid var gridp = 15; //we are defining size of canvas by defining its width and height var canvas_w = grid_w + (gridp*2) + 1; var canvas_h = grid_h + (gridp*2) + 1; var canvas = $('').attr({width: canvas_w, height: canvas_h}).appendTo('body'); var ctx = canvas.get(0).getContext("2d");Here is our method −function ... Read More

Advertisements