---
title: "JavaScript小记"
author: "bepatient"
date: "2010-06-27T17:33:46Z"
tags: []
categories: ["Web前端"]
slug: "javascript"
draft: false
lastmod: "2010-06-27T22:03:15Z"
id: 700301
url: "https://bepatient.iteye.com/blog/700301"
---

<input type="button" value="测试2" onclick="location='ok.jsp'"><span style="color:red">会转到ok.jsp页面，其中location='ok.jsp'等价于：location.href='ok.jsp'也等价于：window.location.href='ok.jsp';</span>

```java
<a href="cart!delete.action?id=${item.product.id}" onclick="return confirm('确定从购物车移除吗？')">删除</a>
```
<span style="color:red">先执行onclick，如果onclick返回的是确定，则执行链接，如果返回取消则不执行。</span>

<a href="#" onclick="var n=document.getElementById('num_${item.product.id}').value;window.location.href='cart!update.action?id=${item.product.id}&number='+n" >变更</a>    <span style="color:red"> 此处应该注意标点符号和onclick有两条语句</span>