Javascript Articles - Page 501 of 607

Autocomplete text input for HTML5?

George John
Updated on 25-Jun-2020 06:38:21

478 Views

Use the autocomplete attribute for autocomplete text input. The autocomplete attribute is used with a form elements to set the autocomplete feature on or off. If the autocomplete feature is on, the browser will automatically show values, based on what users entered before in the field.If the autocomplete feature is off, the browser won’t automatically show values, based on what users entered before in the field.The following are the attribute values −S. NoAttribute ValueDescription1onThis is the default value. The browser automatically complete values based on what users entered before.2offThe browser won’t complete values based on what users entered before. Users have to ... Read More

Is there any way to embed a PDF file into an HTML5 page?

Lakshmi Srinivas
Updated on 27-Jan-2020 08:04:10

759 Views

To embed a PDF file in an HTML5 page, use the element.           HTML iframe Tag               HTML5 Tutorial          

Is there any way of moving to HTML 5 and still promise multi browser compatibility?

Arjun Thakur
Updated on 25-Jun-2020 06:20:19

243 Views

Yes, follow this approach −Move to the HTML5 doctype − Use or even the new elements like Or the newer HTML5 tags or , you can still use the outdated tag.The controls have backward compatibility too. The works the same as in browsers that do not support it.However, if you are working t for legacy Internet Explorer, then use html5shiv. It enables the use of HTML5 sectioning elements in legacy Internet Explorer.

Cross-origin data in HTML5 Canvas

karthikeya Boyini
Updated on 25-Jun-2020 06:39:27

454 Views

For cross-origin data in canvas, add the following attribute to the

Getting Tooltips for mobile browsers in HTML

George John
Updated on 25-Jun-2020 06:22:05

1K+ Views

When you will click on an element with a title attribute, a child element with title text is appended. Let us see an example −For HTML −    The underlined character. jQuery −$("span[title]").click(function () {    var $title = $(this).find(".title");    if (!$title.length) {       $(this).append('' + $(this).attr("title") + '');    } else {       $title.remove();    } });The following is the CSS −.demo {    border-bottom: 2px dotted;    position: relative; } .demo .title {    position: absolute;    top: 15px;    background: gray;    padding: 5px;    left: 0;    white-space: nowrap; }

Enable rear camera with HTML5

Samual Sam
Updated on 25-Jun-2020 06:23:01

356 Views

To enable rear camera, firstly use −MediaStreamTrack.getSources(gotSources);Now, select the source and pass it in as optional into getUserMedia method.This method is useful for users to set permission to use up to one video input device −var a = {    audio: {       optional: [{sourceId: audioSource}]    },    video: {       optional: [{sourceId: videoSource}]    } }; navigator.getUserMedia(a, successCallback, errorCallback);

How to make the web page height to fit screen height with HTML?

Lakshmi Srinivas
Updated on 25-Jun-2020 06:24:42

3K+ Views

Many ways are available to make the web page height to fit the screen height −Give relative heights −html, body {    height: 100%; }You can also give fixed positioning −#main {    position:fixed;    top:0px;    bottom:0px;    left:0px;    right:0px; }You can also use Viewport height to fulfill your purpose −height: 100vh;

Cross domain HTML5 iframe issue

Arjun Thakur
Updated on 25-Jun-2020 06:25:26

545 Views

Use the postMessage method for transferring data across different domains.ExampleYou can try the following code snippet to solve the cross-domain HTML5 iframe issue −// Using postMessage() window.onmessage = function(e) {    e.source.postMessage(document.body.innerHTML, e.origin); }; window.onmessage = function(event) {    alert(e.data); }; // fire document.getElementById('frame1').contentWindow.postMessage('','*');

Is it possible to validate the size and type of input=file in HTML5?

karthikeya Boyini
Updated on 25-Jun-2020 06:26:06

391 Views

Yes, it is possible to validate the size and type of input type = “file”. Use jQuery to get the desired result −                                                        $(function(){             $('form').submit(function(){                var val = true;                   $('input[type=file][data-max-size]').each(function(){                      if(typeof this.files[0] !== 'undefined'){                         var max = parseInt($(this).attr('max-size'),10),                         mySize = this.files[0].size;                         val = max > mySize;                         return val;                      }                   });                   return val;                });             });          

Escaping/encoding single quotes in JSON encoded HTML5 data attributes

George John
Updated on 30-Jul-2019 22:30:22

4K+ Views

To escape single quotes, use json_encode() to echo arrays in HTML5 data attributes.printf('', htmlspecialchars(json_encode(array('html5', ...)), ENT_QUOTES, 'UTF-8'));Or you can also using built-injson_encode(array('html5', ...), JSON_HEX_APOS)

Advertisements