What is the Difference between window.location.href and top.location.href in JavaScript?

Published on June 22, 2013 by abundantcode

Filed under JavaScript

Last modified June 22, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 3626 times

Sometimes, you might be using the JavaScript to get the current location of the page. You might come across 2 properties

  • window.location.href
  • top.location.href

What is the Difference between window.location.href and top.location.href in JavaScript?

The window.location.href will return the location of the current page.

The top.location.href will return the location of the topmost window in the heirarchy. This can be generally be useful when using the frames etc.

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment


x

You might be Interested in these Posts

ES6: The future is now at Warrington on October 18 , 2016

JavaScript North West User Group is hosting its user group meet on the topic "ES6: The future i...

How to append an array to another in JavaScript ?

In JavaScript , you may want to append one array to another array(s) to combine their elements resul...

How to pass a function as parameter in JavaScript ?

There are times when you might want to pass a function as argument to another function in JavaScript...