Front End Technology Articles

Page 506 of 652

How to set the minimum number of lines for an element that must be visible at the top of a page in JavaScript?

George John
George John
Updated on 23-Jun-2020 175 Views

Use the orphans property in JavaScript to set the minimum number of lines for an element that must be visible at the top of a page. You can try to run the following code to learn how to implement orphans property −document.getElementById("p").style.orphansThis is how you can return the orphans property −var res = object.style.orphans;This is how to set the orphans property −object.style.orphans='number|initial|inherit'

Read More

How to use JavaScript Object.defineProperty?

Abhinanda Shri
Abhinanda Shri
Updated on 23-Jun-2020 298 Views

If you want to define a new or modify a property on an object, then use the Object.defineProperty in JavaScript. Use the property like the following −Object.defineProperty(obj, prop, descriptor)The following are the parameters −obj – Property is defined on this object. prop – Name of the property descriptor  − The descriptor for the propertyExampleYou can try to run the following code to learn how to implement Object.defineProperty in JavaScript −                    const obj = {};          Object.defineProperty(obj, 'prop', {             value: 20,             writable: false          });          obj.prop = 10;          document.write(obj.prop);          

Read More

How to set the alignment between the items inside a flexible container when the items do not use all available space with JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 23-Jun-2020 137 Views

Use the alignContent property in JavaScript to set the alignment between the items inside a flexible container.ExampleYou can try to run the following code to implement alignContent property in JavaScript −                    #box {             border: 1px solid #000000;             width: 240px;             height: 150px;             flex-flow: row wrap;             align-content: space-around;             display: flex;          }          #box div {             height: 80px;             width: 80px;          }                              DIV1          DIV2          DIV3             Set                function display() {             document.getElementById("box").style.alignContent = "space-between";          }          

Read More

How to inject JavaScript in WebBrowser control?

Arjun Thakur
Arjun Thakur
Updated on 23-Jun-2020 2K+ Views

To inject JavaScript in WebBrowser control, use the following steps − Firstly, create a Windows Forms application in Visual Studio. Now, drag a WebBrowser control to the form Set the Url property. Right-click the project, choose to Add reference... → COM → Type Libraries Select "Microsoft HTML Object Library"  Add the following code to inject JavaScript.private void myWebBrowser(object sender, WebBrowserDocumentCompletedEventArgs e){      // head element    HtmlElement hElement = weBrowser.Document.GetElementsByTagName("head")[0];    // script element    HtmlElement sElement = weBrowser.Document.CreateElement("script");    IHTMLScriptElement val = (IHTMLScriptElement)sElement.DomElement;    element.text = "function sayHello() {       alert('Weclome')    }";    hElement.AppendChild(sElement);    weBrowser.Document.InvokeScript("How you doing?"); }

Read More

How do I clear the usage of setInterval()?

George John
George John
Updated on 23-Jun-2020 240 Views

The setInterval() method is used evaluate an expression at specified intervals. This function calls function after every duration milliseconds. This goes for unlimited times. Let’s see an example −It triggers alert(‘Hello’) after every 2000 milliseconds, not only once.setInterval(function() { alert('Hello');}, 2000);To clear the usage of setInterval(), use the window.clearInterval() and set the parameter as the ID, likewindow.setInterval();

Read More

Does use of anonymous functions affect performance?

Daniol Thomas
Daniol Thomas
Updated on 23-Jun-2020 385 Views

The usage of anonymous functions affect performance is the sense, you need to create a new function object at each iteration. Anonymous functions are always loaded using a variable name. Anonymous, as the name suggests, allows creating a function without any names identifier. It can be used as an argument to other functions. Call them using a variable name −ExampleThis is how JavaScript anonymous functions can be used −var func = function() {    alert(‘This is anonymous'); } func();Here’s an example −//anonymous function var a = function() {    return 5; }

Read More

Is their JavaScript scroll event for iPhone/iPad?

Abhinanda Shri
Abhinanda Shri
Updated on 23-Jun-2020 414 Views

Yes, iOS capture onscroll events for a scroll. This is called one-finger events. What the user is tapping or touching decides whether an event is generated or not.Here is panning gesture,Image credit − AppleIt can also be touch and hold gesture,Image credit − Apple

Read More

How to set the page-break behavior after an element with JavaScript?

Nikitha N
Nikitha N
Updated on 23-Jun-2020 900 Views

Use the pageBreakAfter property in JavaScript to set the page-break behavior after an element. Use the always property for page after an element.Note − The changes would be visible while printing or viewing the print preview.ExampleYou can try to run the following code to return the page-break behavior after an element with JavaScript −           Heading 1       This is demo text.       This is demo text.       This if footer text.       Set page-break                function display() {             document.getElementById("myFooter").style.pageBreakAfter = "always";          }          

Read More

How to set the page-break behavior inside an element with JavaScript?

Anvi Jain
Anvi Jain
Updated on 23-Jun-2020 3K+ Views

Use the pageBreakInside property in JavaScript to set the page-break behavior inside an element. Use the auto property to insert page break inside an element. Use auto or avoid property value to automatically insert page break inside an element, if needed, or avoid a page break, respectively.Note − The changes would be visible while printing or viewing the print preview.ExampleYou can try to run the following code to return the page-break behavior inside an element with JavaScript −           Heading 1       This is demo text.       This is demo text.       This ...

Read More

How to set the minimum number of lines for an element that must be left at the bottom of a page when a page break occurs inside an element with JavaScript?

Srinivas Gorla
Srinivas Gorla
Updated on 23-Jun-2020 157 Views

Use the orphans property in JavaScript to set the minimum number of lines for an element that should be left at the bottom of a page when a page break occurs inside an element with JavaScript.You can return the orphans property like this −var res = object.style.orphansSet the orphans property like this −object.style.orphans = 'number|initial|inherit'The following are the property values shown above −number − Specify the minimum number of visible lines.Initial − Set property to its defaultInherit − Inherits property from the parent element

Read More
Showing 5051–5060 of 6,517 articles
« Prev 1 504 505 506 507 508 652 Next »
Advertisements