Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCRIPT87: Invalid argument in IE 9, ASP.NET C#

This is working in all other browsers except IE. I am building a link in the code behind in c#:

string link = <a onclick=\"Myfunction('" + Server.UrlEncode(mystring) + "');\" href=\"javascript:void(0);\">Open Pop Up Window</a>

This is my javascript function:

 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?

Here is the html output:

<td><a onclick="Myfunction('urlformyexample.com');" href="javascript:void(0);">Open Pop Up Window</a></td>
like image 630
Drew Avatar asked Mar 06 '12 19:03

Drew


1 Answers

IE9 debugger works and fails on your window.open command.

IE doesn't like the space in the windowName argument – "Manage Domain".

Remove any spaces, hyphens, and underscores (unless you want _blank) and try again.

like image 65
Robert Slaney Avatar answered Oct 26 '22 20:10

Robert Slaney