tags:

views:

74

answers:

1

I have a piece of javascript code. Right now it forces users to manually enter the url of the page they want to insert it on. This is kind of a hassle. Is there a way I can fetch the url of the page in automatically and make everyone's life easier?

+2  A: 
var url = window.location.href;

Reference

John Sheehan
Of course, you'll have to use 'window.location.href' to get the actual URL (window.location just returns the Location object).
Steve Harrison
Thank you. I updated it to atone for my laziness
John Sheehan