网页抛出JavaScript的运行时错误:'函数名'是不确定的。只有IE10 [英] Page throws JavaScript runtime error: 'Function name' is undefined. IE10 only

查看:82
本文介绍了网页抛出JavaScript的运行时错误:'函数名'是不确定的。只有IE10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IE10中工作时,我发现,这是注册还是从code调用的JavaScript函数的后面,是引发异常:

While working on IE10, I have found that the JavaScript functions which are registered or called from the code behind are throwing exception:

的JavaScript运行时错误:'函数名'是不确定的。

"JavaScript runtime error: 'function name' is undefined".

有关例如:
在(!的IsPostBack)块背后code:

For ex: Code behind in the (!IsPostBack) block:

Page.RegisterStartupScript("showGCAlert", "<script language=\"javascript\">ShowGCAlert();</script>");

浏览量:

function ShowGCAlert()
    {

        alert('GCAlert');
        if(document.getElementById('hdnGCAlert').value != "1")
        {
            document.getElementById('divGCAlert').style.display = "Block";
            document.getElementById('chkReminder').focus();
            document.getElementById('btnLogin').disabled = true;
            document.getElementById('Button2').disabled = true;             

        }
        else
        {
            document.getElementById('divGCAlert').style.display = "none";
            document.getElementById('btnLogin').disabled = false;
            document.getElementById('Button2').disabled = false;                
            if (document.getElementById("txtUsername").value != "")
                document.getElementById("txtPassword").focus();
            else
                document.getElementById("txtUsername").focus();
        }

    }

在页面加载其抛出异常,即使 ShowGCAlert()存在动态页面上。

When the page loads its throws the exception even though the ShowGCAlert() exists on the dynamic page.

继续除外设计页面显示后:

After continuing the exception design page shows:

<script language="javascript" src="/ABC/DEF/Scripts/Common.js"></script>
<script language="javascript">
    document.body.style.overflowY="hidden";
    document.body.style.overflowX="hidden";
    var jsAppName ='ABC';
</script>
<script language="javascript">
    function window.onresize() 
    { 
        document.cookie = "resX=" 
                        + document.body.clientWidth 
                        + ";resY=" 
                        + document.body.clientHeight 
                        + ";path=/"; 
    } 
    window.onresize();
</script>
<script type="javascript">
      ShowGCAlert();
</script>
<script language="javascript">
    document.getElementById('txtPassword').focus();
</script>

在IE9或IE10兼容性查看其工作罚款。请告诉我在哪里我做错了。

In ie9 or IE10 compatibility view its working fine. Please show me where i am doing wrong.

推荐答案

尝试使用放置脚本在页面的末尾的RegisterClientScriptBlock 并调用它。

Try placing the script at the end of the page using RegisterClientScriptBlock and call it.

   Page.ClientScript.RegisterClientScriptBlock("showGCAlert", 
     "<script type=\"text/javascript\">ShowGCAlert();</script>");

这篇关于网页抛出JavaScript的运行时错误:'函数名'是不确定的。只有IE10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆