javascript SCRIPT87:IE 9、ASP.NET C# 中的无效参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9590282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SCRIPT87: Invalid argument in IE 9, ASP.NET C#
提问by Drew
This is working in all other browsers except IE. I am building a link in the code behind in c#:
这适用于除 IE 之外的所有其他浏览器。我正在c#后面的代码中建立一个链接:
string link = <a onclick=\"Myfunction('" + Server.UrlEncode(mystring) + "');\" href=\"javascript:void(0);\">Open Pop Up Window</a>
This is my javascript function:
这是我的 javascript 函数:
function Myfunction(pMyString) {
CloseWindow();
var url = "DomainPath/MyPage.aspx?Site=" + pMyString;
win = window.open(url, "Manage Domain", 'toolbar=no,location=no,status=no,directories=no,scrollbars=yes,resizable=no,width='+700+',height='+500);
}
If the function is added to an onclick method in the aspx page, it works in IE. It seems to be only when I am building the link dynamically in the code behind. It will not accept any values as a parameter, and IE always outputs the error: SCRIPT87: Invalid argument with a line number to my function, however I am unable to debug. Have a missed something?
如果在aspx页面的onclick方法中添加了该函数,在IE下就可以使用了。似乎只有当我在后面的代码中动态构建链接时。它不会接受任何值作为参数,并且 IE 总是输出错误:SCRIPT87: Invalid argument with a line number to my function,但是我无法调试。有遗漏吗?
Here is the html output:
这是 html 输出:
<td><a onclick="Myfunction('urlformyexample.com');" href="javascript:void(0);">Open Pop Up Window</a></td>
回答by Robert Slaney
IE9 debugger works and fails on your window.open command.
IE9 调试器在 window.open 命令上工作并失败。
IE doesn't like the space in the windowName
argument – "Manage Domain".
IE 不喜欢windowName
参数中的空格——“管理域”。
Remove any spaces, hyphens, and underscores (unless you want _blank
) and try again.
删除所有空格、连字符和下划线(除非您需要_blank
),然后重试。