Eggo
Eggo

Reputation: 539

Use Javascript/Jquery to to strip down a dynamic URL

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.

Upvotes: 0

Views: 95

Answers (2)

Teody C. Seguin
Teody C. Seguin

Reputation: 238

to get the current page url

var c_url = window.location.href;

Upvotes: 0

mikevoermans
mikevoermans

Reputation: 4007

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

Upvotes: 1

Related Questions