Set Width and Height of a JavaScript Alert Box

Nishtha Thakur
Updated on 16-Jun-2020 13:38:12

4K+ Views

To set the width and height of an alert box in JavaScript, you need to use the custom alert box. This alert box is styled with CSS.Set the width and height of the alert box using the following code, which uses jQuery, a JavaScript library −Example                                function functionAlert(msg, myYes)          {             var confirmBox = $("#confirm");             confirmBox.find(".message").text(msg);             confirmBox.find(".yes").unbind().click(function()       ... Read More

Print Debug Messages in Google Chrome JavaScript Console

Ali
Ali
Updated on 16-Jun-2020 13:35:05

345 Views

To print debug messages in the Google Chrome JavaScript Console, write a script, which is not creating console functions if they do not exist −if (!window.console) console = {}; console.log = console.log || function(){}; console.warn = console.warn || function(){}; console.error = console.error || function(){};Above you can see the following functions are used to log items based on a log, warn or info. It won’t cause errors when the console isn’t available. The following functions work in Google Chrome console −console.log( ); console.warn(); console.error();The Console object is used to access the browser's debugging console. As an example, consider the Web Console ... Read More

Box Stacking Problem

Samual Sam
Updated on 16-Jun-2020 13:33:48

1K+ Views

In this problem a set of different boxes are given, the length, breadth, and width may differ for different boxes. Our task is to find a stack of these boxes, whose height is as much as possible. We can rotate any box as we wish. But there is a rule to maintain.One can place a box on another box if the area of the top surface for the bottom box is larger than the lower area of the top box.Input and OutputInput: A list of boxes is given. Each box is denoted by (length, bredth, height). { (4, 6, 7), ... Read More

Change Styling of JavaScript Alert Button

Ranjit Kumar
Updated on 16-Jun-2020 13:30:26

636 Views

To change the styling of JavaScript alert button, use the custom alert box. You can try to run the following code to change the styling of alert buttons. The button looks different and more fancy −ExampleLive Demo                                function functionAlert(msg, myYes)  {             var confirmBox = $("#confirm");             confirmBox.find(".message").text(msg);             confirmBox.find(".yes").unbind().click(function() {                confirmBox.hide();             }); ... Read More

Write a Form to Assist Browser's Auto-Complete Feature

Krantik Chavan
Updated on 16-Jun-2020 13:30:18

139 Views

The official specification of HTML5 states:When the autofill field name is "on", the user agent should attempt to use heuristics to determine the most appropriate values to offer the user, e.g. based on the element's name value, the position of the element in the document's DOM,  whaUse any of the following as values for the autocomplete attribute:)Field NameMeaning"name"Full name"honoritic-prefix"Prefix or title (e.g. "Mr.", "Ms.", "Dr.", "M||e")"given-name"Given name (in some Western cultures, also known as first name"additional-name"Additional name (in some Western cultures, also know as middle name, forenames other than the first name)"family-name"Family name (in some Western cultures, also know as ... Read More

Why if 0 is Equal to False in JavaScript

mkotla
Updated on 16-Jun-2020 13:28:37

2K+ Views

Let’s see the conditions one by one − if(‘0’ == false)It follows the following rule −If Type(y) is Boolean, return the result of the comparison x == ToNumber(y)The == does type coercion. This means an explicit type conversion is requested to match the type of the two operands. The left side '0' is converted to a number 0. On comparing the two numbers, and since 0 equals 0, the result is true. In this case, this does not work since it does not implies about the truish/falsy nature of the '0' string, since it got coerced before it was compared.if(0)This checks ... Read More

Print Current Year in JavaScript

Giri Raju
Updated on 16-Jun-2020 13:27:38

1K+ Views

To get current year in JavaScript, use the getFullYear() method.ExampleYou can try to run the following code to print current year −Live Demo           Click below to get the current year:       Display Year                      function display() {             var date = new Date();             var res = date.getFullYear();             document.getElementById("test").innerHTML = res;          }          

Bootstrap 4 Border Warning Class

Alex Onsman
Updated on 16-Jun-2020 13:26:02

223 Views

Use the border-warning class in Bootstrap to set orange border to an element.To add orange border, set the div as −   Warning (Orange border) You can try to run the following code to implement the border-warning class −ExampleLive Demo       Bootstrap Example                             .new {       width: 200px;       height: 150px;       margin: 10px;     }       The following is a Rectangle:   Warning (Orange border)

Get Current Date and Time in JavaScript

varma
Updated on 16-Jun-2020 13:25:45

486 Views

To get current date and time in JavaScript, use the Date object.ExampleYou can try to run the following code to display date and time −                          document.getElementById("currentDate").innerHTML = Date();          

Use window.print() Function to Print a Page

usharani
Updated on 16-Jun-2020 13:25:14

1K+ Views

To print a page in JavaScript, use the window.print() method. It opens up the standard dialog box, through which you can easily set the printing options like which printer to select for printing.ExampleYou can try to run the following code to learn how to print a page −Live Demo           Click to Print                function display() {             window.print();          }          

Advertisements