I am trying to extract the page name from a complex url. This post is how I am attempting to do this. Now I am able to get the url of the page but once I try to do anything with it it fails. I am using this in a SharePoint page.
//WORKS!
var url = window.location;
alert(url);
//ALERTS NOTHING
//PREVENTS ALL JAVASCRIPT AFTER THIS FROM RUNNING AS WELL
var url = window.location;
var url_parts = url.split(‘/’);
var main_url = url_parts[0];
alert(main_url);
window.locationis not a string, it’s aLocationobject and it has no methodsplit. It does have a lot of methods for getting parts of the URL, though, that you may want to look at that may even do what you’re trying to do:https://developer.mozilla.org/en/DOM/window.location
If all else fails, you can use
.toString().split…