[英]JS function works from console, but onclick returns blank page
I'm working on some HTML5 app with JS, and I've encountered a problem. 我正在使用JS开发一些HTML5应用程序,但是遇到了问题。 Function written in js is working when called from console, but when clicking on button with onclick it returns a blank page. 从控制台调用时,用js编写的函数可以正常工作,但是当使用onclick单击按钮时,它将返回空白页面。
here's the function: 这是函数:
function open() {
document.getElementById("chatBox").innerHTML = localStorage.chat;
return false;
}
and here's button: 这是按钮:
<button id="openConButton" onclick="open()">Open</button>
Oh, and important one: other function from this script file are working just fine. 哦,重要的一点:此脚本文件中的其他功能正常工作。 Any ideas? 有任何想法吗?
Common pitfall; 常见的陷阱; your button is calling document.open()
. 您的按钮正在调用document.open()
。 Just rename the function. 只是重命名功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.