1

注意:以下仅是实时服务器上的问题。在我的本地开发中,一切正常。

我的标记中有一个 javascript 函数,如下所示:

    function openNewWin(url) { 
        var x = window.open(url, 'mynewwin', 'width=500,height=500,toolbar=0,scrollbars=0'); 
        x.focus();
    }

在按钮单击事件中,我调用以下命令:

     ScriptManager.RegisterStartupScript(this, this.GetType(), "OpenWin", "openNewWin('" + url + "')",true);

这不起作用,我在 chrome 中得到以下内容:

Uncaught SyntaxError: Unexpected identifier ScriptResource.axd:448
_ScriptLoader$_loadScriptsInternal ScriptResource.axd:448
_ScriptLoader$_loadScriptsInternal ScriptResource.axd:453
_ScriptLoader$_loadScriptsInternal ScriptResource.axd:453
_ScriptLoader$_loadScriptsInternal ScriptResource.axd:453
_ScriptLoader$_nextSession ScriptResource.axd:476
_ScriptLoader$_loadScriptsInternal ScriptResource.axd:462
_ScriptLoader$_nextSession ScriptResource.axd:476
_ScriptLoader$loadScripts ScriptResource.axd:372
PageRequestManager$_onFormSubmitCompleted ScriptResource.axd:1480
$type.createDelegate ScriptResource.axd:628
$type.getHandler ScriptResource.axd:4338
raise ScriptResource.axd:7429
WebRequest$completed ScriptResource.axd:7433
Sys.Net.XMLHttpExecutor._onReadyStateChange

在 IE 中我得到:

Message: Expected ')'
Line: 1
Char: 51
Code: 0
URI: http://mysite.com/postage/printpostage.aspx

我无法弄清楚我的 javascript 有什么问题。它在开发中完美运行。

更多详细信息:我正在使用 ASP.NET WebForms。执行代码的按钮嵌套在 UpdatePanel 中。

谢谢你的帮助。

编辑

我删除了 ScriptManager.RegisterStartupScript 并尝试在单击按钮时做一些简单的事情,但我得到了同样的错误。我想这是其他原因造成的。我该如何解决这个问题?

编辑#2:

我从头开始,它看起来像是带有 Scriptmanager.registerstartupscript 的任何代码。例如,我尝试使用以下方法,但遇到了同样的问题:

    catch (Exception ex)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "AlertError", "alert('Error: " + ex.Message + "');", true);
    }
4

0 回答 0