The location object is part of the window object (but also of the document object), and provides access to the current URL and its components. It can be accessed through the window.location property (or document.location).

window.location (or document.location ) returns the full URL address. But if you assign it a value (a string with a URL address) will load the page from that URL (makes redirect to that address).

- Example, it displays the full address of the page, and after five seconds it redirects to another address (in iframe if the script is into an <iframe>).
document.write('<p>Current address:<br>'+window.location+'<br><br>- After 5 seconds redirects to: //</p>');
window.setTimeout(()=>{window.location ='//';}, 5000);
This object has properties and methods that can be called with the syntax:

Properties of the location object

Methods of the location object

Daily Test with Code Example

What attribute makes the input text box to not be modified by the user?
checked="checked" readonly="readonly" disabled="disabled"
<input type="text" value="fixed-value" readonly="readonly" name="a_name" />
What CSS property allows you to create rounded corners in your webpage design?
background-size border-size border-radius
.class {
  border:2px solid blue;
What instruction displays a confirmation dialog box to the viewer, who must then click OK or Cancel to proceed?
indexOf() confirm() prompt()
var ques = window.confirm("The result of 0+0 is 0?");
if (ques) alert("Corect");
else alert("Incorrect");
Indicate the PHP function that returns the lowest number of the parameter values.
floor() ceil() min()
$min_nr = min(12, 8, 25, 13);
echo $min_nr;        // 8
The location object

Last accessed pages

  1. jQuery UI draggable - Drag elements (10491)
  2. Create simple Website with PHP (28026)
  3. Insert, Select and Update NULL value in MySQL (51609)
  4. Upload Script for Gallery of Images and Audio files (8061)
  5. RegExp - Regular Expressions in ActionScript (3605)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (103)
  2. Read Excel file data in PHP - PhpExcelReader (59)
  3. Register and show online users and visitors (55)
  4. PHP-MySQL free course, online tutorials PHP MySQL code (52)
  5. JavaScript Course - Free lessons (43)