我正在尝试调用从 aspx 页面加载到我的母版页中的我的 javascript 函数之一。
以下是我目前正在使用的代码:
ScriptManager.RegisterStartupScript(Me.Page, GetType(String), "showNotifier", "showNotifier(3000,'green','test');", True)
javascript代码是这样的:
function showNotifier(delayTime, color, theMsg) {
var theDivName = '#Notifier';
e.preventDefault();
$(theDivName).css("background", color);
$(theDivName).text(theMsg);
$(theDivName).animate({ top: 0 }, 300, null);
$(theDivName).css("position", "fixed");
//Hide the bar
$notifyTimer = setTimeout(function () {
$(theDivName).animate({ top: -100 }, 1500, function () {
$(theDivName).css("position", "absolute");
});
}, delayTime);
});
这就是我在后面的代码中调用它的地方:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
ScriptManager.RegisterStartupScript(Me.Page, GetType(String), "showNotifier", "showNotifier(3000,'green','test');", True)
End If
End Sub
当我运行我的页面并加载该 aspx 页面时,它显示此错误:
Microsoft JScript runtime error: 'showNotifier' is undefined.
什么会导致这种情况?