邀朋友种豆,一起分享吧
喜欢购买正品行货?那就去品牌街

JavaScript加载顺序导致Sys未定义错误

来自:种豆 时间:2017-12-29 阅读:648次 原文链接
下面是网友写的使用客户端脚本对UpdateProgress编程的示例,调试时出现"Sys"未定义错误。<script language ="javascript" type ="text/javascript">
var prm
= Sys.WebForms.PageRequestManager.getInstance();
function CancelAsyncPostBack()
{
if (prm.get_isInAsyncPostBack())
{
prm.abortPostBack();
}
}
</script>
<body>
<form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTUyOTg1NTQyOQ9kFgICAw9kFgICAw9kFgJmD2QWAgIBDw8WAh4EVGV4dAURMjAwNy00LTYgMTQ6MDU6NDlkZGREYQN58Yj+m9IGN+2epJ2FNje08g==" />
</div>

<script type="text/javascript">
<!--
var theForm
= document.forms['form1'];
if (!theForm) {
theForm
= document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value
= eventTarget;
theForm.__EVENTARGUMENT.value
= eventArgument;
theForm.submit();
}
}
// -->
</script>

<!--这里才是关键-->
<script src="/TerryleeAjaxStudy/WebResource.axd?d=UFQkbcHWN57exE0SpCYaRw2&amp;t=633088654060000000" type="text/javascript"></script>
<script src="/TerryleeAjaxStudy/ScriptResource.axd?d=2JLTz86mw9i3F9-cOuBKoPn4kWuUYxqaqYrTK5ZEXGiXCJVts1BhQPPE-lsYBPO3Co4PJZV7CEo_dR-PEdUtid6GlB3FC3FdPyFgmKCfS-o1&amp;t=633108589400000000" type="text/javascript"></script>
<script src="/TerryleeAjaxStudy/ScriptResource.axd?d=2JLTz86mw9i3F9-cOuBKoPn4kWuUYxqaqYrTK5ZEXGiXCJVts1BhQPPE-lsYBPO3Co4PJZV7CEo_dR-PEdUtifwll-8QFJzlg0feOhuzoK_POVL9oSBZhsSxHELDiDLr0&amp;t=633108589400000000" type="text/javascript"></script>
......

    从上面的示例可以看出,在程序引用ScriptResource.axd之前就调用了“Sys.WebForms....”,这就会出现“Sys”未定义,将调用的JavaScript放到最后就能解决示例中出现的“Sys”未定义的问题。

 
关于种豆 ┊ 联系我们 ┊ 免责声明 ┊ 发帖须知 ┊ 请提意见 ┊ 站点地图
本站为个人爱好兴趣分享网站,不代表本人观点,如有侵权请联系QQ3371650278进行处理
sowsoy.com 版权所有 Copyright©2010-2020 浙ICP备10212932号
Email:sowsoy#hotmail.com