Input Type URL in HTML5

Nancy Den
Updated on 29-Jan-2020 08:38:28

335 Views

This accepts only URL value in HTML5. This type is used for input fields that should contain a URL address. If you try to submit a simple text, it forces to enter only URL address either in https://www.qries.com format or in http://qries.com format.                    Enter URL :                    

Detect a Particular Feature through JavaScript with HTML

Nishtha Thakur
Updated on 29-Jan-2020 08:37:27

195 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 */ }

Check Web Browser Support in HTML5

Smita Kapse
Updated on 29-Jan-2020 08:35:39

279 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:

Log Error to Console with Web Workers in HTML5

karthikeya Boyini
Updated on 29-Jan-2020 08:34:25

696 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...." );          }                        

Why HTML5 Web Workers are Useful

Anvi Jain
Updated on 29-Jan-2020 08:33:46

202 Views

JavaScript was designed to run in a single-threaded environment, meaning multiple scripts cannot run at the same time. Consider a situation where you need to handle UI events, query and process large amounts of API data, and manipulate the DOM.JavaScript will hang your browser in situation where CPU utilization is high. Let us take a simple example where Javascript goes through a big loop:           Big for loop                function bigLoop(){             for (var i = 0; i

Resize Image Before Submitting the Form in HTML5

karthikeya Boyini
Updated on 29-Jan-2020 08:22:08

338 Views

To resize the image before submitting the form, you need to use the drawImage() method.Scale the original image and draws the scaled version on the canvas at [0,0]context.drawImage( img, 0,0,img.width,img.height, 0,0,myWidth,UseHeight );Above, we saw the following:Here,var myWidth = Math.floor( img.width * Scale ); var myHeight = Math.floor( img.height * Scale );And,var x = Math.floor( ( world.width - myWidth) / 2 ); var y = Math.floor( ( world.height - myHeight) / 2 );

DataTransfer Object Attributes

Nitya Raut
Updated on 29-Jan-2020 08:21:27

548 Views

The DataTransfer object holds data about the drag and drop operation. This data can be retrieved and set in terms of various attributes associated with the DataTransfer object.The following are the attributes:Sr.No.DataTransfer attributes and their description1dataTransfer.dropEffect [ = value ]Returns the kind of operation that is currently selected.This attribute can be set, to change the selected operation.The possible values are none, copy, link, and move.2dataTransfer.effectAllowed [ = value ]Returns the kinds of operations that are to be allowed.This attribute can be set, to change the allowed operations.The possible values are none, copy, copyLink, copyMove, link, linkMove, move, all and uninitialized.3dataTransfer.typesReturns a DOMStringList ... Read More

Drop Target Events in HTML5

Lakshmi Srinivas
Updated on 29-Jan-2020 08:20:54

147 Views

To accept a drop, the drop target has to listen to at least three events. The dragenter event, which is used to determine whether the drop target is to accept the drop. If the drop is to be accepted, then this event has to be canceled. The dragover event, which is used to determine what feedback is to be shown to the user. If the event is canceled, then the feedback (typically the cursor) is updated based on the dropEffect attribute's value. Finally, the drop event, which allows the actual drop to be performed.

Data Transfer Object in HTML5

Jennifer Nicholas
Updated on 29-Jan-2020 08:20:22

415 Views

The event listener methods for all the drag and drop events accept Event object that has a readonly attribute called dataTransfer. The event.dataTransfer returns DataTransfer object associated with the event as follows:function EnterHandler(event) {    DataTransfer dt = event.dataTransfer;    … }You can try to run the following code to implement DataTransfer object:                    #boxA, #boxB { float:left;padding:10px;margin:10px; -moz-user-select:none; }          #boxA { background-color: #6633FF; width:75px; height:75px; }          #boxB { background-color: #FF6699; width:150px; height:150px; }             ... Read More

Image Scale on Mouse Over in HTML5 Canvas

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

345 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, 0, img.width>>1, img.height>>1); }

Advertisements