【发布时间】:2012-07-10 14:57:39
【问题描述】:
我是一个初学者,尝试我的第一个程序在脚本标签的 scr 属性中添加外部 jscript 文件,按照我搜索的所有步骤操作,但它没有按应有的方式工作。有人可以帮我解决这个问题吗?
- 我有一个 aspx 表单,一个按钮 onclick 调用内部 javascript 函数。 我也有一键 onclick 调用外部 .js 文件功能。
这是我的 aspx 代码
<head runat="server">
<script type="text/javascript" language="javascript" src="ExternalJScript.js">
function Myfunction()
{
document.getElementById("htmlbutton").innerHTML = "This is Button from Javascript function";
alert("Hi Function Called from Javascript");
}
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<button type="button" id="htmlbutton" onclick="Myfunction()">This is html button</button><br />
<button type="button" id="Button1" onclick="ExternalJSFileFunction()" value="Call File">HI</button>
</div>
</form>
这是我的 .js 代码
ExternalJSFileFunction()
{
alert("I m from external file");
}
【问题讨论】:
-
我在 aspx 页面中的 javascript 函数工作正常。但外部不是。它给了我 Microsoft JScript 运行时错误:预期对象。
标签: javascript asp.net jscript.net