Javascript Course

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

Which tag is used in <table> to create table header cell?
<thead> <th> <td>
  <th>Title 1</th>
  <th>Title 2</th>
Which CSS property sets the distance between lines?
line-height word-spacing margin
.some_class {
  line-height: 150%;
Which function opens a new browser window.
alert() confirm() open()
document.getElementById("id_button").onclick = function(){"");
Indicate the PHP function that returns an array with names of the files and folders inside a directory.
mkdir() scandir() readdir()
$ar_dir = scandir("dir_name");
The location object

Last accessed pages

  1. PHP PDO - Select query, fetch (23919)
  2. SHA256 Encrypt hash in JavaScript (13171)
  3. querySelector and querySelectorAll (16212)
  4. Get Duration of Audio /Video file before Upload (9575)
  5. Display multiple groups of images (3402)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (522)
  2. Register and show online users and visitors (361)
  3. PHP-MySQL free course, online tutorials PHP MySQL code (273)
  4. querySelector and querySelectorAll (266)
  5. JavaScript Course - Free lessons (265)