Forum Moderators: open

Message Too Old, No Replies

JavaScript URL withOUT HTTP query?

www.example.com/file.php without?this=that

         

JAB Creations

6:20 pm on Apr 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How can I get the current URL without any queries in JavaScript?

- John

Demaestro

6:32 pm on Apr 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



once you get the URL split on '?' and then use the [0] element.

pseudo code
var URL = URL
var URL_parts = URL.split('?')
var URL_no_qs = URL_parts[0]

JAB Creations

6:42 pm on Apr 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Very cool, thanks!

- John

var url = window.location.href;
var urlsplit = url.split("?");
alert(urlsplit[0]);