0

I have this function:

popstate = function(url){
$('#ajaxloadcontent').load(url+"#ajaxloadcontent > *");
}

I need it to get the current page URL, lets just call that: "http://www.pearlsquirrel.com/index.php"

I then need to somehow use jquery and strip down the URL to just what is after "http://www.pearlsquirrel.com/" and be left with "index.php." Is there any kind of jquery or javascript function that would be able to help me do this?

Also, if it were to just get "http://www.pearlsquirrel.com," I would need the function also set the URL to a default index.php.

2 Answers 2

1

You could use any of these variables: http://www.w3schools.com/jsref/obj_location.asp

Sign up to request clarification or add additional context in comments.

3 Comments

Yeah pathname is what you're looking for. Also to get it without the initial slash var path = window.location.pathname.substr(1);
location.pathname is what I am looking for. Thank you so much!
So you consider this the answer? :)
0

to get the current page url

var c_url = window.location.href;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.