无论出于何种原因,我都无法让以下代码在 IE9 中运行,但它可以在 Firefox、Chrome 和 Opera 中运行:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Laughing Man Productions²-Administrator Portal</title>
<!--[if !IE 9]> <!--><link rel="stylesheet" type="text/css" href="http://www.lmpgames.com/WEB401/W2/css/login_page.css"/><!--<![endif]-->
<!--[if IE 9]>
<link rel="stylesheet" type="text/css" href="http://www.lmpgames.com/WEB401/W2/css/login_page_IE.css"/>
<![endif]-->
</head>
<body>
<div class="login_bg">
<form action="" method="post" enctype="multipart/form-data">
<fieldset class="fset">
<div class="username_text">
Username/Email Address:
<span class="username_field">
<input name="txtbUName" type="text" style="background-color:#DDDDDD;" value="Username" size="20" maxlength="60" />
</span>
</div><br/>
<div class="password_text">
Password:
<span class="password_field">
<input name="txtbPWord" type="password" style="background-color:#DDDDDD;" value="Password" size="20" maxlength="16" />
</span>
</div><br/>
<div class="sub">
<input name="btnSubmit" type="button" onclick="formatUName(this.form)" value="Submit" />
</div>
<textarea name="txtaFOutput" class="txta" cols="1" rows="1">
</textarea>
</fieldset>
</form>
</div>
<script type="application/javascript">
function formatUName(form)
{
//Set up variables and references for use later on
var button = form.btnSubmit;
var txta = form.txtaFOutput;
var username = form.txtbUName;
var password = form.txtbPWord;
var uName = "default";
var pWord = "";
uName = username.value; //Obtain the value of the username field on submit
//Then remove spaces from the value and change all letters to uppercase
uName = uName.replace(/\s+/g, '');
uName = uName.toUpperCase();
//Finally print the formatted username to the textarea
txta.value = uName + " is your username";
}
</script>
</body>
</html>
当我在 IE 中加载页面并单击提交时,没有任何反应。我尝试将 .value 更改为 innerHTML 和 innerText 但它们都不能在 IE 中工作。
编辑:
在摆弄 IE 之后,我终于设法让调试运行,它吐出了这个错误:
行:23 错误:无法获取属性“appendChild”的值:对象为空或未定义
编辑2:
忽略前面的错误。IE 允许 Vuze 通过我不知道 Vuze 安装的插件注入 Javascript 代码。禁用它们,现在新的错误消息是关于我的函数名称的:
第 35 行:属性“formatUName”的值为 null 或未定义,不是 Function 对象