window.location在IE中路径问题

来源:互联网 发布:艺恩数据 电视剧网播 编辑:程序博客网 时间:2024/06/05 11:54

如果在jsp的head中指定了basepath,如下,则表示客户端路径以basepath所指定的路径为相对地址开始寻址。但是使用window.location时,在IE浏览器中不识别basepath,此时window.location是以本js页面为相对路径的,此处推荐使用绝对路径,在火狐等浏览器中识别basepath。

当css中引用url时,在使用了basepath、不区分浏览器的的情况下,如果css代码在jsp文件中,则url的相对路径以basepath开始,如果css代码在css文件中,则url以当前css为相对路径。

<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><%=basePath %><html><head>    <base href="<%=basePath%>"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Insert title here</title><script type="text/javascript" src="model1/js/submit.js"></script> <link rel="stylesheet" type="text/css" href="model1/css/submit.css"></head>
0 0
原创粉丝点击