HTML DOM Location Origin Property

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

121 Views

The Location origin property returns the string corresponding to the URL’s protocol, hostname, host port number (if specified).SyntaxFollowing is the syntax −Returning value of the origin propertylocation.originExampleLet us see an example for Location origin property − Live Demo Location origin    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Location-origin Current URL:    var divDisplay = document.getElementById("divDisplay");    var urlSelect = document.getElementById("urlSelect");    function getorigin(){       divDisplay.textContent = 'URL Origin: '+location.origin;    } OutputThis will produce the following output −Before clicking ‘Get origin’ button −After clicking ‘Get origin’ button −

Launch a Program Using C++

Samual Sam
Updated on 30-Jul-2019 22:30:26

3K+ Views

Here we will see how to start some third-party application like notepad or anything using C++ program. This program is very simple, we can use command prompt command to do this task.We will pass the application name inside the system() function. This will open it accordingly.Example#include using namespace std; int main() {    cout >> "Opening Nodepad.exe" >> endl;    system("notepad.exe"); }Output

Find Segmentation Error in C and C++ Using GDB

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

1K+ Views

The segmentation error is one of the runtime error, that is caused because of the memory access violation, like accessing invalid array index, pointing some restricted address etc. In this article, we will see how to detect this type of error using the GDB tool.Let us see the code and respective steps to locate the error.Example#include main() {    int* ptr = NULL;    *ptr = 1; //trying to access unknown memory location    printf("%p", ptr); }Compile the code using ‘gcc –g program_name.c’, and run using ‘./a.out’Outputsoumyadeep@soumyadeep-VirtualBox:~/Cpp_progs$ ./a.out Segmentation fault (core dumped)The segmentation error occurred.Write ‘gdb ./a.out core’soumyadeep@soumyadeep-VirtualBox:~/Cpp_progs$ gdb ... Read More

Add Button to Notifications in Android

Smita Kapse
Updated on 30-Jul-2019 22:30:26

2K+ Views

This example demonstrate about How to add button to notifications in androidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Intent ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.Button ; public class MainActivity extends AppCompatActivity {    public static final String NOTIFICATION_CHANNEL_ID = "10001" ... Read More

Prepend String to Entire Column in MongoDB

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

211 Views

Prepend string to entire column in MongoDB using aggregate framework. Let us first create a collection with documents −> db.prependDemo.insertOne({"StudentFirstName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccf3bcedceb9a92e6aa1955") } > db.prependDemo.insertOne({"StudentFirstName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccf3bd3dceb9a92e6aa1956") } > db.prependDemo.insertOne({"StudentFirstName":"Robert"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccf3bd8dceb9a92e6aa1957") }Following is the query to display all documents from a collection with the help of find() method −> db.prependDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5ccf3bcedceb9a92e6aa1955"), "StudentFirstName" : "John" } {    "_id" : ObjectId("5ccf3bd3dceb9a92e6aa1956"),    "StudentFirstName" : "Chris" } {    "_id" : ObjectId("5ccf3bd8dceb9a92e6aa1957"), ... Read More

Difference Between Math.ceil and Math.round Methods in JavaScript

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

6K+ Views

Math.ceil() and Math.round() methods differ in a way that the former round off a number to its nearest integer in upward direction of rounding(towards the greater value) whereas the latter round off a number to its nearest integer in downward direction of rounding(towards lower value). Let's examine the two methods individually.Math.ceil()Math.ceil() method round off number passed as parameter to its nearest integer so as to get greater value.ExampleIn the below example when a number 5.34 passed as a parameter, Math.ceil() round off it in to 6, which is a greater value than actual number.Live Demo document.write(Math.ceil(5.34)); ... Read More

Create a Box Layout in Java

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

3K+ Views

To create a Box Layout in Java Swing, use the BoxLayout class. Here, we have also set that the components should be laid our left to right or top to bottom −Box box = new Box(BoxLayout.X_AXIS); box.add(button1); box.add(button2); box.add(button3); box.add(button4); box.add(Box.createGlue()); box.add(button5); box.add(button6); box.add(button7); box.add(button8);Above, we have 8 buttons in our Box Layout. We have separated 4 buttons each using the createGlue() method.The following is an example to create a BoxLayout in Java −Examplepackage my; import java.awt.BorderLayout; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JScrollPane; public class SwingDemo {    public static void main(String args[]) {     ... Read More

MySQL Query to Decrease Value by 10 for a Specific Value

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

636 Views

Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Score int    ); Query OK, 0 rows affected (0.89 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Score) values(67); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Score) values(78); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Score) values(90); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Score) values(56); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+----+-------+ ... Read More

HTML li Value Attribute

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

257 Views

The value attribute of the element is used to set the value of the list item. Since the value is a number, it would be set only for the ol element in HTML i.e. the ordered list.Following is the syntax −Above, num is the value of the list item in an ordered list. Let us now see an example to implement the value attribute of the element −Example Live Demo Subjects Following are the subjects −    Maths    Science    English    French Remaining subjects −    Coffee    Accounts    Programming    Networking ... Read More

EOFException in Java: Handling and Solutions

Venkata Sai
Updated on 30-Jul-2019 22:30:26

3K+ Views

While reading the contents of a file in certain scenarios the end of the file will be reached in such scenarios a EOFException is thrown.Especially, this exception is thrown while reading data using the Input stream objects. In other scenarios a specific value will be thrown when the end of file reached.Let us consider the DataInputStream class, it provides various methods such as readboolean(), readByte(), readChar() etc.. to read primitive values. While reading data from a file using these methods when the end of file is reached an EOFException is thrown.ExampleFollowing program demonstrates how to handle the EOFException in Java. Live ... Read More

Advertisements