tomcat端上的页面,用javascript不能更改img标签的src,但在本地却可以
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<link rel="stylesheet" type="text/css"
href="css/imgareaselect-animated.css" />
<script type="text/javascript">
function PreviewImage(imgFile) {
var filextension = imgFile.value.substring(imgFile.value
.lastIndexOf("."), imgFile.value.length);
filextension = filextension.toLowerCase();
if ((filextension != '.jpg') && (filextension != '.gif')
&& (filextension != '.jpeg') && (filextension != '.png')
&& (filextension != '.bmp')) {
alert("对不起,系统仅支持标准格式的照片,请您调整格式后重新上传,谢谢 !");
imgFile.value = null;
} else {
document.getElementById("bigcover").src = imgFile.value;
document.getElementById("littlecover").src = imgFile.value;
}
}
</head>
<body>
<img src="img\a.png" title="上传封面" alt="上传封面" name="bigcover"
id="bigcover" />
<input type="file" name="cover" onchange="PreviewImage(this)" />
</body>
</html>
--------------------编程问答--------------------
理论上在浏览器打开tomcat端上的jsp页面后,页面的代码应该已经转换成html了,但为什么不行,真郁闷
补充:Java , Web 开发