简体   繁体   English

JS函数可从控制台运行,但是onclick返回空白页

[英]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.

相关问题 Onclick JS函数调用,仅在Safari控制台中返回“找不到变量” - Onclick JS function call, returns “Can't find variable” only in Safari Console JS 函数在控制台上有效,但在代码中无效 - JS function works on console, but not in code JS功能在chrome控制台上有效,但从插件加载时无效 - JS function works on chrome console but not when load from plugin 使用locatin.href =…的Javascript函数从控制台调用时有效,而不是从按钮中的onClick调用时有效 - Javascript function using `locatin.href = …` works when called from console, not when called from `onClick` in a button JS; 防止onClick函数在页面重新加载之前发生 - JS; prevent onClick function from happening until page reloads React JS:浏览器控制台显示“未捕获的TypeError:type.apply不是函数”,页面空白 - React JS: Browser console displays, “Uncaught TypeError: type.apply is not a function” and page comes out blank (React,JS,TS)该功能在“onClick”上有效,但在“KeyPress”上无效 - (React, JS, TS) the function works "onClick" but not on "KeyPress" 部署的 React 应用程序显示一个空白页面并且控制台返回错误 404 - Deployed React App Shows a Blank Page and Console Returns Error 404 jQuery函数在Firebug控制台中有效,但在页面中无效 - jquery function works in the firebug console but not in the page 其他功能的OnClick-JS - OnClick from other function - JS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM