iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 413 forks source link

window.location.href gets href of previous page #1537

Closed kenshinman closed 8 years ago

kenshinman commented 8 years ago

Hi, I'm using iron router in my project. So when I go from the homepage to another template/ page I tried getting the href of the current with console.log(window.location.href), I get the URL of the previous page until I refresh the current page before I get it's URL. How can this be resolved?

Batistleman commented 8 years ago

When are you executing that command? Perhaps the page is nog completely loaded?

Perhaps you could give this a try:

Router.current().route.path()
rdb commented 8 years ago

This may be because window.location is not reactive. I suggest using Iron.Location.get() instead, which is a reactive alternative that comes with iron-router.