我有以下网页在IE中被扭曲,但是哪个有效,我找不到任何问题... Here's a link to the page在FF,Safari,Chrome中看起来不错,但是不正确IE8。
我也在Chrome中收到此错误:“未捕获的TypeError:无法调用null(匿名函数)onload”的方法'焦点'。
任何建议都很棒 - 代码如下,所使用的包含文件出现在其他页面上,完全没有问题:
<!--#include virtual="/System/Startup_FranchiseClient.asp"-->
<%
EnsurePageIsHTTPS
Dim blnShowResults : blnShowResults = False
Dim SQLCommand
Dim objConn
Dim rsUser
Dim rsEmail
Dim strTempPassword
Set objConn = Server.CreateObject("ADODB.Connection")
Set rsUser = Server.CreateObject("ADODB.RecordSet")
Set rsEmail = Server.CreateObject("ADODB.RecordSet")
Dim strPassword_Encrypted
Dim objEncrypt : Set objEncrypt = New Encrypt_MD5
If Request.Form("ForgotPassword") = "1" then
SQLCommand = "SELECT * FROM Clients WHERE EmailAddress = '" & CleanSQLText(Request.Form("strUsername")) & "'"
objConn.Open strConn
rsUser.Open SQLCommand, objConn, adOpenKeySet, adLockOptimistic
if rsUser.RecordCount <> 1 then
strSecurity_LoginError = "Sorry, your details could not be found. Please check your email address and try again.<br>"
Else
strTempPassword = NewGUID()
strTempPassword = Mid(strTempPassword, 2, 8)
strPassword_Encrypted = objEncrypt.EncryptMD5(strTempPassword)
rsUser("ResetPasswordOnNextLogin") = True
rsUser("Password") = strPassword_Encrypted
rsUser.Update
blnShowResults = True
SQLCommand = "SELECT '" & CleanSQLText(strTempPassword) & "' AS NewPassword, EmailAddress FROM uvw_EmailContent_ForgotPassword WHERE EmailAddress = '" & CleanSQLText(Request.Form("strUsername")) & "'"
rsEmail.Open SQLCommand, objConn, adOpenStatic, adLockReadOnly
SendPublicFranchiseEmailTemplate GetSiteConfig("Public_AutoEmailsFrom"), rsEmail("EmailAddress"), "Inside Guides Password Assistance", "EmailTemplate_ForgotPassword", True, rsEmail
blnShowResults = True
End if
rsUser.Close
Set rsUser = Nothing
End if
%>
<!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=iso-8859-1" />
<title>Inside-Guides.co.uk - Advertiser Admin</title>
<!--#include virtual="/Assets/Templates/Public/Franchise/HeadCSS.asp"-->
</head>
<body class="advertisers" onload="javascript:document.getElementById('strUsername').focus();">
<!--#include virtual="/Assets/Templates/Public/Franchise/TemplateStartPages.asp"-->
<h1>Forgot Password</h1>
<%
If blnShowResults = False then
%>
<div class="bg MainCopy">
<p>Please enter your email address below and we will email you your password:</p><br />
<p class="ErrorText"><% = strSecurity_LoginError %></p>
<form name="LoginForm" method="post" action="ForgotPassword.asp">
<input type="hidden" name="ForgotPassword" value="1" />
<table>
<tr>
<th align="left" valign="middle" style="width:110px;">
Email Address:
</th>
<td align="left" valign="middle">
<input type="text" name="strUsername" value="" />
</td>
<td align="right" valign="middle">
<input type="submit" class="submit" value="Send Password" />
</td>
</tr>
</table>
</form>
</div>
<%
Else
%>
<%
If Session("Role_Developer_DebugUser") = True then
%>
<h1><font color="red"><% = strTempPassword %></font></h1>
<%
End if
%>
<span class="MainCopy">A new password has been emailed to you. Please check your email and use the temporary password provided to access your account<br /> via the link provided. You can then choose a new password.</span>
<%
End if
%>
<!--#include virtual="/Assets/Templates/Public/Franchise/TemplateEnd.asp"-->
</body>
</html>
<!--#include virtual="/System/Shutdown.asp"-->
答案 0 :(得分:2)
你是对的,这是Javascript。您没有ID为strUsername的元素。将id =“strUsername”添加到要聚焦的输入元素。
<input type="text" id="strUsername" name="strUsername" value="" />
答案 1 :(得分:0)
document.getElementById('strUsername').focus();
此调用失败,因为您在页面上没有包含 ID 的元素。您需要分配ID属性以及name属性:
<input type="text" id="strUsername" name="strUsername" value="" />
就像错误消息告诉你的那样,它无法通过该ID找到元素,因此该函数返回null,并且您无法在空引用上调用focus()
。