ถ้าฉันใช้:
alert(window.location.href);
ฉันได้รับทุกอย่างรวมถึงสตริงการสืบค้น มีวิธีที่จะได้รับส่วน URL หลักเช่น:
http://mysite.com/somedir/somefile/
แทน
http://mysite.com/somedir/somefile/?foo=bar&loo=goo
อาจเป็นไปได้ซ้ำกับการลบการสอบถามออกจาก URL
—
Alex Angas