我是 Javascript 的新手,也是使用 Ratchet 的新手。我尝试构建一个小应用程序来熟悉。我编写了以下代码,但它不太工作。在后退按钮上,我想调用我的 javascript 来保存注释。但是我收到一个错误,找不到 note_back()。我做错了什么?
索引.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Notes</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link href="css/ratchet.css" rel="stylesheet">
<script src="js/ratchet.js"></script>
</head>
<body>
<header class="bar bar-nav">
<a class="icon icon-plus pull-right" data-transistion="slide-in" href="note.html"></a>
<h1 class="title">Notes</h1>
</header>
<div class="content">
<ul class="table-view">
</ul>
</div>
</body>
</html>
note.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Note</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link href="css/ratchet.css" rel="stylesheet">
<script src="js/ratchet.js"></script>
<script src="js/notecontroller.js"></script>
</head>
<body>
<header class="bar bar-nav">
<a class="icon icon-left pull-left" onclick="javascript:note_back()"></a>
<a class="icon icon-trash pull-right" onclick="javascript:note_delete()"></a>
<h1 class="title">Add Note</h1>
</header>
<form>
<br>
<br>
<br>
<textarea id="notetext" rows="10"></textarea>
</form>
</body>
</html>
notecontroller.js
function note_back() {
console.log("reached note_back");
localStorage.setItem("note",document.getElementById("notetext"));
window.location.href="index.html";
}
function note_delete() {
console.log("reached note_delete");
localStorage.removeItem("note");
window.location.href="index.html";
}
截屏:
(作为一个附带问题,为什么我看不到 note.html?)