views:

246

answers:

2

I have created a web page to screen scrape a site, while scraping from the other site; there is some error on that site so it's throwing an error (object expected). But finally I get my result perfectly.

It shows that the error occurs in my program. Is it possible to bypass those errors (without showing them on the screen). I don't want to show those errors and also is it possible to bypass the alert box without showing it on the screen while scraping.

Please guide me.

A: 

I don't know how do you scrap the site, I don't know, but if yo're installing the content in javascript by eval or something like that, you can try try-catch block :

try
{
   // your content injected to page here.
}
catch(err)
{
   alert(err.description);
}

or you can clear script elements before including to your site with this regex :

(<script\b[^>]*>.*?</script>)
Canavar
+1  A: 

You could try to redirect window.onerror:

var _oldonerror = window.onerror;
window.onerror = function(errorMsg,url,lineNr) { return true; };
KooiInc
please explain, what these lines will do? Will it throw the error
praveenjayapal