Javascript 示例程序无法运行

标签 javascript html

我正在尝试从链接运行示例 javascript 代码:Link

FF 和 IE 上没有任何反应,扫描后,它只是清除了文本字段。这里有什么问题吗?

代码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="javascript">
    function ini()
    {

    // Retrieve the code
    var code =document.getElementById ('code_read_box').value;

    alert(code);

    // Return false to prevent the form to submit
    return false;

    }

</script>

</head>


<body>

    <form onsubmit = "return ini()">

    <input type="text" id="code_read_box" value="" />

    </form>
</body>
</html>

最佳答案

<script type="text/javascript">

而不是

<script type="javascript">

关于Javascript 示例程序无法运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3834977/

相关文章:

javascript - 单击链接时运行 PHP SQL 查询命令

javascript - 除了明显的布局/CSS 问题之外的浏览器兼容性问题?

javascript - 在 Div 后面画线

javascript - 当选择 radio 并单击按钮时,如何运行函数?

html - PayPal:选择具有数量的多个项目

javascript - json 未按正确顺序打印

javascript - react + Firestore : Return a variable from a query

javascript - 长时间暂停后恢复应用程序时如何处理场景(未终止)

javascript - dom 元素在脚本之前加载

javascript - 在 iOS 上同时播放 Html5 视频和音频?