window.location.href = "D:/Test02"怎么改?
时间: 2024-09-19 18:10:18 浏览: 84
`window.location.href = "D:/Test02"`这行代码的作用是将当前页面的URL指向本地磁盘上的指定路径`D:\Test02`。但是请注意,浏览器出于安全考虑通常不允许直接访问本地文件系统,尤其是对于非同源的资源(比如从http到file协议)。如果你想在本机测试一个HTML文件,通常推荐使用服务器环境(例如Apache、IIS等)先把这些文件托管起来,然后通过网络地址访问。
如果你想改变窗口的URL(例如跳转到一个新的HTML页面),可以修改为:
```javascript
// 跳转至同源下的另一个页面
window.location.href = "/Test02.html"; // 假设你的网站根目录是"/"
// 或者跳转到完全新的URL,假设是一个外部网站
window.location.href = "https://www.example.com/Test02.html";
```
如果你的目标是下载而非浏览文件,可以创建一个`a`标签并模拟点击:
```javascript
const aElement = document.createElement('a');
aElement.href = "D:/Test02";
aElement.download = 'Test02'; // 设置下载名称
aElement.click();
```
相关问题
DataSyncMDRClick(row){ this.dialogVisible=true; this.dialogSrc = `./P37040102.html?InstanceGuid=${row.InstanceGuid}` //this.dialogSrc = `https://app-emp-v7-test.ccshcc.cn/P85/Modules/P85010102.html?InstanceGuid=${row.InstanceGuid}` // var data = { // title: '审批详情' + uuid(), // url: K7WebSite + `modules/P85010102.html?InstanceGuid=${row.InstanceGuid}` // }; // openTab(data); //window.location.href=`./P85010102.html?InstanceGuid=${row.InstanceGuid}` // openTab(_def) },
这段代码是一个点击事件的处理函数 `DataSyncMDRClick`,当点击某一行时会触发该函数。在函数中,首先将 `dialogVisible` 设置为 `true`,以显示对话框。然后根据点击行的 `row` 对象的 `InstanceGuid` 属性,构建一个 URL 地址,并将其赋值给 `dialogSrc` 变量。最后,注释掉了一些关于打开新标签页或跳转页面的代码,这些代码可能是用于打开指定 URL 地址的新标签页或在当前页面跳转到指定 URL 地址的。根据注释的不同情况,你可以根据需要将其恢复并进行相应的操作。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="./CSS/index.css"> <script type="text/javascript" src="./js/jquery-3.3.1.js"></script> <title>Document</title> </head> <body> <div class="divclass"> <button onclick="getLogIn()">log in</button> <hr> <input type="file" id="uploadFile" name="uploadFile" /> <button onclick="addFile()" type="submit">提交</button> <hr> <input type="text" id="downloadfilename"> <button onclick="downloadFile()" target="new target">下载</button> </div> </body> <!-- http://127.0.0.1:8082/localTest/upload --> <!-- http://127.0.0.1:8082/localTest/testDownload --> <script> function getLogIn() { window.location.href = "./pages/login.html"; } function downloadFile() { var filename = document.getElementById("downloadfilename").value; //window.open("http://127.0.0.1:8082/localTest/testDownload?filename=" + encodeURI(filename)); window.open("http://127.0.0.1:8088/api/DownloadByCustomer?filename=" + encodeURI(filename)); } function addFile() { var formData = new FormData(); formData.append("file1", document.getElementById('uploadFile').files[0]); $.ajax({ url: 'http://127.0.0.1:8088/admApi/admUpload', type: 'POST', data: formData, // 上传formdata封装的数据包 //dataType: 'JSON', timeout: 10000, cache: false, // 不缓存 processData: false, // jQuery不要去处理发送的数据 contentType: false, // jQuery不要去设置Content-Type请求头 success: function (res) { console.log(res) console.log("上传成功"); return alert("上传成功"); }, error: function (sd) { console.log(sd) console.log("上传失败"); return alert("上传失败"); } }); }; </script> </html>
这是一个 HTML 页面,包含一个按钮和三个输入框。点击按钮会跳转到 login.html 页面,其中一个输入框可以用来上传文件,另一个输入框可以输入文件名,点击下载按钮会下载指定文件名的文件。其中,上传文件的代码使用了 jQuery 的 ajax 方法,将文件数据包装为 FormData 格式上传。下载文件的代码使用了 window.open 方法,将文件名作为参数拼接在 URL 后面进行下载。页面中的地址都是本地地址,需要根据实际情况进行修改。
阅读全文
相关推荐







新闻发布系统>>新闻管理>>查询新闻 <form action="SelectNews" method="post"> 请输入查询条件:<input type="text" name="key"> <input type="submit" value="查询"> </form>
编号 标题 类型 发布人 发布日期 状态 是否头条 操作 <c:forEach items="${newsList }" var="news"> <input type="checkbox" name="newsIds" value="${news.nid}"> ${news.nid } ${news.title } ${news.type } ${news.userName } ${news.pubtime } adadada <c:choose> <c:when test="${news.state==0 }">待审核</c:when> <c:when test="${news.state==1 }">通过</c:when> <c:otherwise>未通过</c:otherwise> </c:choose> <c:choose> <c:when test="${news.top==0 }">否</c:when> <c:otherwise>是</c:otherwise> </c:choose> ${news.top==0?"是":"否" } 查看 <c:if test="${user.rule==0 || user.uid ==news.uid }"> 修改 </c:if> <c:if test="${user.rule==0 }"> 删除 </c:if> <c:if test="${user.rule==0 }"> 审核</c:if> </c:forEach> <c:if test="${user.rule==0}"> <button type="button">批量删除</button> </c:if> </body> <script type="text/javascript"> function banchDelete(){ var idsArray = document.getElementsByName("newsIds"); var nidArray=[];//用于存储需要删除的新闻编号 for(k in idsArray){ if(idsArray[k].checked){ nidArray.push(idsArray[k].value); } } if(nidArray.length==0){ alert("请选择要删除的新闻"); return } window.location.href="./newsBanchDelete.jsp?nids="+nidArray.join(",");//window.location.href 方法是javascript的页面跳转代码 } </script>


新闻发布系统>>新闻管理>>查询新闻 <form action="SelectNews" method="post"> 请输入查询条件:<input type="text" name="key"> <input type="submit" value="查询"> </form>
编号 标题 类型 发布人 发布日期 状态 是否头条 操作 <c:forEach items="${newsList }" var="news"> <input type="checkbox" name="newsIds" value="${news.nid}"> ${news.nid } ${news.title } ${news.type } ${news.userName } ${news.pubtime } <c:choose> <c:when test="${news.state==0 }">待审核</c:when> <c:when test="${news.state==1 }">通过</c:when> <c:otherwise>未通过</c:otherwise> </c:choose> <c:choose> <c:when test="${news.top==0 }">否</c:when> <c:otherwise>是</c:otherwise> </c:choose> ${news.top==0?"是":"否" } 查看 <c:if test="${user.rule==0 || user.uid ==news.uid }"> 修改 </c:if> <c:if test="${user.rule==0 }"> 删除 </c:if> <c:if test="${user.rule==0 }"> 审核</c:if> </c:forEach> <button type="button" >批量删除</button> </body> <script type="text/javascript"> function banchDelete(){ var idsArray = document.getElementsByName("newsIds"); var nidArray=[]; for(k in idsArray){ if(idsArray[k].checked){ nidArray.push(idsArray[k].value); } } if(nidArray.length==0){ alert("请选择要删除的新闻"); return } window.location.href="./newsBanchDelete.jsp?nids="+nidArray.join(","); } </script>这段代码优化使user.rule=0的用户才能看见批量删除的按钮

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="com.test.bean.Goods,java.util.ArrayList" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>购物车</title> <style type="text/css"> table{border-collapse:collapse;} td{border:1px solid black; text-align:center; } #deal{margin-left:200px} </style> </head> <body> <jsp:useBean id="cart" class="com.test.bean.Cart" scope="session"></jsp:useBean> <%if(cart==null||cart.getGoodslist().size()==0) out.println("购物车空空如也.....返回商品首页"); else{ ArrayList<Goods>goodslist=cart.getGoodslist(); %> 当前购物车共有<%=cart.getGcount() %>件物品 返回商品首页
序号 商品号 商品名称 价格 数量 小计 描述 <%for(int i=0;i<goodslist.size();i++){ Goods goods=goodslist.get(i); %> <%=i+1 %> <%=goods.getGid() %> <%=goods.getGname() %> <%= String.format("%.2f", goods.getGprice())%> <%=goods.getGcount() %> <%=String.format("%.2f", goods.getGprice()*goods.getGcount()) %> 删除 <%}%>
总计<%=String.format("%.2f",cart.getTotal())%> <input type="button" id="deal" value="购买" /></input> <%}%> <script type="text/javascript"> var dealbutton=document.getElementById("deal"); dealbutton.onclick=function(){ var cf=confirm("确定购买吗?"); if(cf==true){ window.location.href="Servlet/DealServlet"; } } </script> </body> </html> 修改删除功能,在购物车物品数量大于1的情况下点击“删除”时减少1个,等于1时删除此项商品;

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<body>
<input type="button" value="新增" onclick="add()">
ID
姓名
年龄
密码
修改 删除
<c:if test="${not empty list }">
<c:forEach items="${list }" var="user" varStatus="s">
${s.count}
${user.username}
${user.age}
${user.password}
修改
删除
</c:forEach>
</c:if>
<script >function add(){
location.href="add.jsp";
}
function updatemethod(userid) {
var id = parseInt('<%= session.getAttribute("id") %>');
if (userid != id) {
alert("你不能修改别人的信息");
} else {
window.location.href = "update.jsp";
}
}
function deletemethod(userid) {
var id = parseInt('<%= session.getAttribute("id") %>');
if (userid != id) {
alert("你不能删除别人的信息");
} else {
if(confirm("你确定要删除自己的信息吗?")) {
window.location.href = "index.jsp";
}
}
}</script>
</body>
</html>上述代码哪里报错,要如何修改





添加
修改
删除
手动运行数据更新器 选中 时间 总居民消费CPI 食品类CPI 衣着类CPI 居住类CPI 服务类CPI 交通通信类CPI 教育类CPI 医药类CPI 其他类CPI <c:forEach items="${cpi}" var="i"> <input name="radiobox" type="radio" value=${i.TIMES}/> <c:if test="${i.TIMES==999999}"> 预测本月 </c:if> <c:if test="${i.TIMES!=999999}"> ${i.TIMES} </c:if> ${i.CPI} ${i.FOOD} ${i.CLOTH} ${i.RESIDE} ${i.SERVICE} ${i.TRANS} ${i.EDU} ${i.MEDIC} ${i.OTHER} </c:forEach> 我希望页面在点击修改和删除的时候把单选框的value提交给服务器,我应该怎么改
