function getContextPath() { var pathname = location.pathname return pathname.substr(0, pathname.indexOf('/', 1))}//该片段来自于http://www.codesnippet.cn/detail/2010201410678.html
来源: http://www.codesnippet.cn/detail/2010201410678.html