How to get the application name and version information of a browser in JavaScript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

2K+ Views

Javascript has provided a navigator object with which we can find any information regarding the browser. To get the application name and version information, navigator object has provided navigator.appName() and navigator.appVersion() respectively. Let's discuss each of them individually.Application Name of the browserTo get the application name, the navigator object has provided navigator.appName(). It may sound weird that "Netscape" is the application name for IE11, Chrome, Firefox, and Safari. So the output we get when we use navigator.appName() is Netscape.ExampleLive Demo document.write(navigator.appName); OutputNetscapeBrowser version informationTo get the browser version information, the navigator object has provided ... Read More

Add n binary strings in C++?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

137 Views

Here we will see how we can write a program that can add n binary numbers given as strings. The easier method is by converting binary string to its decimal equivalent, then add them and convert into binary again. Here we will do the addition manually.We will use one helper function to add two binary strings. That function will be used for n-1 times for n different binary strings. The function will work like below.AlgorithmaddTwoBinary(bin1, bin2)begin    s := 0    result is an empty string now    i := length of bin1, and j := length of bin2   ... Read More

HTML DOM lastChild Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

40 Views

The HTML DOM lastChild property returns the last element node as node object of the specified node.NOTE − This property does not ignore text and comment nodesSyntaxFollowing is the syntax −Returning lastChild nodenodeList.lastChildExampleLet us see an example for HTML DOM lastChild property − Live Demo HTML DOM lastChild    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    }    ul{       width: ... Read More

How to hide and display JCombobox with a JCheckBox in Java?

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

373 Views

To toggle visibility with JCheckBox, use isVisible() method:JCheckBox toggleVisibility = new JCheckBox("Hide/Show"); toggleVisibility.setSelected(comboBox.isVisible()); toggleVisibility.addItemListener(e -> {    comboBox.setVisible(e.getStateChange() == ItemEvent.SELECTED); });The following is an example to hide and display JCombobox with a JCheckBox in Java:Exampleimport java.awt.BorderLayout; import java.awt.event.ItemEvent; import javax.swing.*; public class SwingDemo {    JFrame frame;    SwingDemo(){       frame = new JFrame("ComboBox");       String Sports[]={"Select", "Tennis", "Cricket", "Football"};       JComboBox comboBox = new JComboBox(Sports);       comboBox.setBounds(50, 50, 90, 20);       frame.add(comboBox, BorderLayout.CENTER);       JCheckBox toggleVisibility = new JCheckBox("Hide/Show");       toggleVisibility.setSelected(comboBox.isVisible());       toggleVisibility.addItemListener(e ... Read More

Java DatabaseMetaData supportsGroupBy() method with example

Rishi Raj
Updated on 30-Jul-2019 22:30:26

31 Views

The SQL GROUP BY clause is used in collaboration with the SELECT statement to arrange identical data into groups. This GROUP BY clause follows the WHERE clause in a SELECT statement and precedes the ORDER BY clause.SyntaxThe basic syntax of a GROUP BY clause is shown in the following code block. The GROUP BY clause must follow the conditions in the WHERE clause and must precede the ORDER BY clause if one is used.SELECT column1, column2 FROM table_name WHERE [ conditions ] GROUP BY column1, column2 ORDER BY column1, column2The supportsGroupBy() method of the DatabaseMetaData interface is used to determine whether ... Read More

Explain about add and assignment(+=) operator in detail in javascript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

116 Views

add and assignment(+=) operatorThe add and assignment(+=) operator reduces the code little bit.It may not much influential  in small codes whereas coming to long codes it's use can't be ignored. Live DemoExample    var tot = 0;    var a = [1,45,78,9,78,40];    for(var i = 0; i

IPC through shared memory

Chandu yadav
Updated on 30-Jul-2019 22:30:26

3K+ Views

Shared memory is a memory shared between two or more processes. However, why do we need to share memory or some other means of communication?To reiterate, each process has its own address space, if any process wants to communicate with some information from its own address space to other processes, then it is only possible with IPC (inter process communication) techniques. As we are already aware, communication can be between related or unrelated processes.Usually, inter-related process communication is performed using Pipes or Named Pipes. Unrelated processes (say one process running in one terminal and another process in another terminal) communication ... Read More

How to right-align a menu in the menu bar with Java?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

707 Views

Let’s say we added a menu to the MenuBar −JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);Add the glue component in between the menus to align some of them on the right, for example −menuBar.add(Box.createHorizontalGlue());The menu added after the usage of above method, would get right-aligned −JMenu sourceMenu = new JMenu("Source"); sourceMenu.setMnemonic(KeyEvent.VK_S); menuBar.add(sourceMenu);The following is an example to right-align a menu in the menu bar with Java −Examplepackage my; import java.awt.event.KeyEvent; import javax.swing.Box; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; public class SwingDemo {    public static void main(final String args[]) {       ... Read More

How to insert mm/dd/yyyy format dates in MySQL?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

4K+ Views

For this, use STR_TO_DATE(). Following is the syntax −insert into yourTableName values(STR_TO_DATE(yourDateValue, yourFormatSpecifier));Let us first create a table −mysql> create table DemoTable    (    ShippingDate date    ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command : Here, we are inserting formatted dates using date formats like m, d, y, etc −mysql> insert into DemoTable values(STR_TO_DATE('06-01-2019', '%m-%d-%Y')); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(STR_TO_DATE('01-31-2019', '%m-%d-%Y')); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(STR_TO_DATE('02-01-2018', '%m-%d-%Y')); Query OK, 1 row affected (0.27 sec)Display all records ... Read More

Removing an element from C++ std::vector<> by index?

Anvi Jain
Updated on 30-Jul-2019 22:30:26

241 Views

Remove an element from C++ std::vector by index can be done by following way −Example Live Demo#include #include using namespace std; int main() {    vector v; //declare vector    //insert elements into vector    v.push_back(-10);    v.push_back(7);    v.push_back(6);    // Deletes the first element (v[0])    v.erase(v.begin() );    for (int i = 0; i < v.size(); i++)       cout

Advertisements