首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >javascript中的Window.Alert()不工作

javascript中的Window.Alert()不工作
EN

Stack Overflow用户
提问于 2014-08-29 13:02:02
回答 1查看 438关注 0票数 0

我在网上找到了一些javascript代码。我正在使用它,但在这里我无法获得windows.alert()方法。下面是我的代码。

代码语言:javascript
运行
复制
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Javascriptexmple.aspx.cs"     Inherits="MIS_Javascriptexmple" %>

<!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 runat="server">
<script language="javascript" type="text/javascript">
  function Validate() {
      // Get the password entered in the page
      var Pass = $get("MyPass").value;
      // Encrypte the password
      var MD5 = hex_md5(Pass);
      // Run ValidateLogin PageMethod to validate the password
      PageMethods.ValidateLogin(MD5, Done);
      window.alert(MD5);
  }
  function Done(result) {
      // Alert the boolean result returned from PageMethod
      alert(result);
  }
  </script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
    <asp:ScriptManager EnablePageMethods="true" ID="ScriptManager1" runat="server">
    <Scripts>
      <asp:ScriptReference Path="md5.js" />
    </Scripts>
  </asp:ScriptManager>

<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
      <asp:TextBox ID="MyPass" runat="server"></asp:TextBox>
      <input id="BtnLogin" type="button" value="Login" onclick="Validate();" />
    </ContentTemplate>
  </asp:UpdatePanel>
</div>
</form>

请告诉我我遗漏了哪里?

EN

回答 1

Stack Overflow用户

发布于 2014-08-29 13:11:42

未定义$get。未定义hex_md5。未定义PageMethods.ValidateLogin。包括定义这些函数的脚本,您就可以开始工作了。如下所示:

代码语言:javascript
运行
复制
<script src="md5script.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
  function Validate() {
      // Get the password entered in the page
      var Pass = $get("MyPass").value;
      // Encrypte the password
      var MD5 = hex_md5(Pass);
      // Run ValidateLogin PageMethod to validate the password
      PageMethods.ValidateLogin(MD5, Done);
      window.alert(MD5);
  }
  function Done(result) {
      // Alert the boolean result returned from PageMethod
      alert(result);
  }
  </script>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25561966

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档