faqts : Computers : Programming : Languages : JavaScript : Language Core : Functions

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 19 people (89%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How can i read curent url using javascript. Is there any function available for this

Apr 10th, 2007 04:00
Johannes Findorf, Shunmuga prasath,


Use window.location, location has many options:

window.location.hash (after #)
window.location.host (www.faqts.com)
window.location.hostname (faqts.com)
window.location.href (complete url
window.location.pathname 
window.location.port (port number)
window.location.protocol (http...)
window.location.search (everything after the ?)
window.location.reload (not in ie, but used to bypass cache)
window.location.replace (opens new url)