Multiple choice general knowledge

What property would you use to redirect a visitor to another page?

  1. document.URL

  2. window.location.href

  3. .document.location.href

  4. link.href

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The correct answer is B. window.location.href.

To redirect a visitor to another page, you can use the property window.location.href in JavaScript. By setting the value of window.location.href to the URL of the desired page, the visitor's browser will automatically navigate to that page.

Option A (document.URL) represents the current URL of the document and does not redirect to another page.

Option C (.document.location.href) is not a valid property in JavaScript.

Option D (link.href) is not a valid way to redirect a visitor using JavaScript.