对象不支持“split”属性或方法

初学者问题:为什么location.split("?")不支持此方法?
var   UrlParts=location.split( "? "); 
跳出错误:对象不支持此属性和方法, 
window.localhost不是返回一个URL字符串么?字符串不是支持split么?为什么说不支持?

------解决方案--------------------------------------------------------
location.href.split 
location.toString().split 
------解决方案--------------------------------------------------------
<script language=javascript> 
alert(location.href.toString().split( "? ")) 
</script>
原文地址:https://www.cnblogs.com/y0umer/p/3839193.html