[英]javascript is not working in mozilla but working in other browers
使用的技术:-Asp.Net 2.0
代码:-见下文
描述:-下面给出的hello代码在ie和其他版本中都可以正常工作,但在所有mozila版本中均不能正常工作。javascript很容易确定两个文本框的值。 您可以轻松理解。
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="javascript_test.aspx.cs" Inherits="javascript_test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<script type ="text/jscript">
var _txtamount;
var _txtins;
var _txtinsamount;
function test()
{
var temp;
_txtamount = document.getElementById("txtamount");
_txtins = document.getElementById("txtins");
_txtinsamount = document.getElementById("txtinsamount");
if (_txtinsamount.value !='')
{
temp = parseFloat(_txtamount.value) / parseFloat(_txtinsamount.value);
}
else
{
temp = 0
}
_txtins.value = temp;
}
</script>
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="myform" runat="server" name="myform">
<div>
<asp:TextBox ID="txtamount" runat="server" ></asp:TextBox>
<asp:TextBox ID="txtinsamount" runat="server" onblur="test();"></asp:TextBox>
<asp:TextBox ID="txtins" runat="server"></asp:TextBox></div>
</form>
</body>
</html>
您的<script>
标记需要包装在<head>
元素或<body>
元素中; 它不能只是<html>
的直接子代。
[edit]更重要的是您的“类型”值,如此处的其他答案所述。
您正在使用text/jscript
作为<script>
类型。 改用text/javascript
:
<script type ="text/javascript">
JScript是Microsoft自己的ECMAScript版本-难怪它可以在IE上运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.