Internet Explorer (IE) starts giving Javascript error when I tried to open Pop-up Dialog, Which works perfect with Fire Fox and Chrome.
So If you are getting javascript error in IE on doing Javascript:Window.Open
Javascript Error: Invalid Argument or Syntax Error
Example: (In Asp.net Code Behind)
string url = "MyTestURL?qsTestId=" + TestId;
string winFeatures = "toolbar=no,status=no,menubar=no,height=400,width=400";
string winPoPUpScript = string.Format("javascript:window.open('{0}', 'My Test Popup', '{1}');", url, winFeatures);
lnkCounter.Attributes.Add("onclick", winPoPUpScript);
Opening Window.open with javascript works perfectly with Firefox and Chrome, but will give error with IE.
Solution (Quick Fix):
You need to remove spaces from 2nd Argument of Javascript Function Window.open() to make it work with IE. If your second argument of Window.Open contains spaces than you may receive javascript errors like Invalid Argument or Syntax Error.
To Fix the above code we need remove spaces from 2nd argument of Window.open
Example: (In Asp.net Code Behind)
string url = "MyTestURL?qsTestId=" + TestId;
string winFeatures = "toolbar=no,status=no,menubar=no,height=400,width=400";
string winPoPUpScript = string.Format("javascript:window.open('{0}', 'MyTestPopup', '{1}');", url, winFeatures);
lnkCounter.Attributes.Add("onclick", winPoPUpScript);
1 comment:
Great post. Thanks for providing the detail lacking from IE's error message.
Post a Comment