I’m working on a project which needs to use youtube api. The html and javascript works fine in different browsers. Yet When I just WPF’s webbrowser to run it, I get the following error:
Script Error
line:1
char:1
Error: Syntax Error
Code:0
URL about://:/
Do you want to continue running scripts on this page?
yes no
When I click yes, the message box went away and the program just works fine. I comment out most of the content on the html file and found that the following sentence caused this problem:
google.load("swfobject", "2.1");
So now, I just want to catch this error, just don’t want the messagebox to popup. I tried
try{
google.load("swfobject", "2.1");
}catch(err)
{alert("caught");}
Yet, I still get the initial error box. Is there anyway to remove the error box? Thank you very much.
You can’t actually use
try/catchblocks to catch syntax errors. A syntax error means that the parser can’t correctly parse the JavaScript. Syntax errors happen before the code is ran.