Found 598 Articles for Front End Scripts

How to send a cross-document message with HTML?

Nancy Den
Updated on 29-Jan-2020 07:26:04

202 Views

Create a new web browsing context either by creating new iframe or new window. We can send the data using with postMessage() and it has two arguments. They are asmessage − The message to sendtargetOrigin − Origin nameLet us see an example to send a message from iframe to button:var iframe = document.querySelector('iframe'); var button = document.querySelector('button'); var clickHandler = function(){    iframe.contentWindow.postMessage('The message to send.','https://www.tutorialspoint.com); } button.addEventListener('click',clickHandler,false);

HTML5 Microdata Attributes

Samual Sam
Updated on 29-Jan-2020 07:25:23

183 Views

Microdata introduces five global attributes that would be available for any element to use and give context for machines about your data.AttributeDescriptionItemscopeThis is used to create an item. The itemscope attribute is a boolean attribute that tells that there is Microdata on this page, and this is where it starts.Itemtype This attribute is a valid URL which defines the item and provides the context for the properties.ItemidThis attribute is a global identifier for the item.ItempropThis attribute defines a property of the item.ItemrefThis attribute gives a list of additional elements to crawl to find the name-value pairs of the item.Read More

Properties for HTML5 Canvas to create shadows

Lakshmi Srinivas
Updated on 29-Jan-2020 07:05:42

154 Views

HTML5 canvas provides capabilities to create nice shadows around the drawings. All drawing operations affected by the four global shadow attributes.     Sr.No.                                         Property and Description1shadowColor [ = value ]This property returns the current shadow color and can be set, to change the shadow color.2shadowOffsetX [ = value ]This property returns the current shadow offset X and can be set, to change the shadow offset X.3shadowOffsetY [ = value ]This property returns the current shadow offset Y and can be set, ... Read More

How can I handle Server-Sent Events in HTML5?

karthikeya Boyini
Updated on 29-Jan-2020 07:04:00

167 Views

To handle Server-Sent Events in HTML5, you can try to run the following code:                    document.getElementsByTagName("eventsource")[0].addEventListener("server-time", eventHandler, false);          function eventHandler(event)          {             // Alert time sent by the server             document.querySelector('#ticker').innerHTML = event.data;          }                                                    [TIME]          

Difference between Session Storage and Local Storage in HTML5

Daniol Thomas
Updated on 30-Jul-2019 22:30:22

811 Views

Session StorageThe Session Storage is designed for scenarios where the user is carrying out a single transaction but could be carrying out multiple transactions in different windows at the same time.Local StorageThe Local Storage is designed for storage that spans multiple windows and lasts beyond the current session. In particular, Web applications may wish to store megabytes of user data, such as entire user-authored documents or a user's mailbox, on the client side for performance reasons.HTML5 introduces the localStorage attribute which would be used to access a page's local storage area without no time limit and this local storage will ... Read More

HTML5 tag

Lakshmi Srinivas
Updated on 29-Jan-2020 06:42:19

239 Views

The HTML5 tag is used to draw SVG Gradients. Yes, modern browsers support it.The following is the HTML5 version of an SVG example that would draw an ellipse using the tag and would use the tag to define an SVG radial gradient. Similar way you can use the tag to create SVG linear gradient.                    #svgelem{             position: relative;             left: 50%;             -webkit-transform: translateX(-40%);             -ms-transform: translateX(-40%);             transform: translateX(-40%);          }             SVG                     HTML5 SVG Gradient Ellipse                                                                              

Apply gravity between two or more objects in HTML5 Canvas

Nishtha Thakur
Updated on 29-Jan-2020 06:41:21

230 Views

To apply gravity between two or more object in Canvas:var distX = ob1.x - ob2.x, distY = ob1.y - ob2.y; var val = distX *distX + distY * distY; var r = Math.sqrt(val); var F = 50 / val; var rhat_x = distX / r; var rhat_y = distY / r; var Fx = F * rhat_x; var Fy = F * rhat_y; ob1.vx += -Fx; ob1.vy += -Fy; ob2.vx += Fx; ob2.vy += Fy;

Detect area of a PNG that is not transparent with HTML

Lakshmi Srinivas
Updated on 29-Jan-2020 06:40:56

508 Views

To detect an area of a PNG that is not transparent: You need to first get the buffer You need to get 32-bits reference of that buffer Scan 0 widths to find x1 edge Scan width 0 to find x2 edge Height to find the y1 edge Height 0 to find the y2 edge

To “user-scalable=no” or not to “user-scalable=no” in HTML5

Rishi Rathor
Updated on 30-Jul-2019 22:30:22

238 Views

For responsive design, you do not have to use user-scalable=no. Use it only if you want your application to look more like a native app.Zooming is a key feature for accessibility and you need to keep that in mind. You can control that users won't break your design if they zoom in. If you are doing responsive and your design breaks when zooming in, then you're not doing it right.If you totally need to use it, then keep in mind that zooming is an important accessibility feature that is used by many people.

canvas.style.display = “block” not working in HTML5

karthikeya Boyini
Updated on 29-Jan-2020 06:40:33

267 Views

Change the setTimeout() to use a function reference. It works as the function available at the time the reference.The reference will be transferred to the timeout event callback rather than a string reference:window.setTimeout(startNow, 2000);Set it like the following:setTimeout(startNow, 1000); function startNow () {    alert(‘Working correctly!'); }

Advertisements