Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to suppress javascript error while using WebClient

How to suppress javascript error while using WebClient

Scheduled Pinned Locked Moved Visual Basic
csharpjavascripthtmlasp-net
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MAP Tiger
    wrote on last edited by
    #1

    Hi I am using the following code to retrieve an HTML page contents but it is throwing an exception for certain page of javascript type. Following is the code used to retrieve the page.

        Dim objWebClient As New WebClient()
        Dim objUTF8 As New System.Text.UTF8Encoding()
        Dim strRequestHTML As String
        strRequestHTML = objUTF8.GetString(objWebClient.DownloadData(New Uri("http://search.live.com/results.aspx?q=basic")))
    

    Here the error is thrown while downloading the data that an unspecified error occurred at line #. I want to suppress this error, please suggest me any mod which could do the trick. I would be so thankful to you. Thanks and Regards,

    MAP Tiger Tiger Softwares Software Designer and Developer VB.NET, ASP.NET, VFP

    N M 2 Replies Last reply
    0
    • M MAP Tiger

      Hi I am using the following code to retrieve an HTML page contents but it is throwing an exception for certain page of javascript type. Following is the code used to retrieve the page.

          Dim objWebClient As New WebClient()
          Dim objUTF8 As New System.Text.UTF8Encoding()
          Dim strRequestHTML As String
          strRequestHTML = objUTF8.GetString(objWebClient.DownloadData(New Uri("http://search.live.com/results.aspx?q=basic")))
      

      Here the error is thrown while downloading the data that an unspecified error occurred at line #. I want to suppress this error, please suggest me any mod which could do the trick. I would be so thankful to you. Thanks and Regards,

      MAP Tiger Tiger Softwares Software Designer and Developer VB.NET, ASP.NET, VFP

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Try to supply request headers as a valid JS supported browser. This may avoid JS errors. I don't think that you can suppress it.

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

      M 1 Reply Last reply
      0
      • N N a v a n e e t h

        Try to supply request headers as a valid JS supported browser. This may avoid JS errors. I don't think that you can suppress it.

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

        M Offline
        M Offline
        MAP Tiger
        wrote on last edited by
        #3

        Hi Thanks for the reply. Can you please give me an example? Regards,

        MAP Tiger Tiger Softwares Software Designer and Developer VB.NET, ASP.NET, VFP

        1 Reply Last reply
        0
        • M MAP Tiger

          Hi I am using the following code to retrieve an HTML page contents but it is throwing an exception for certain page of javascript type. Following is the code used to retrieve the page.

              Dim objWebClient As New WebClient()
              Dim objUTF8 As New System.Text.UTF8Encoding()
              Dim strRequestHTML As String
              strRequestHTML = objUTF8.GetString(objWebClient.DownloadData(New Uri("http://search.live.com/results.aspx?q=basic")))
          

          Here the error is thrown while downloading the data that an unspecified error occurred at line #. I want to suppress this error, please suggest me any mod which could do the trick. I would be so thankful to you. Thanks and Regards,

          MAP Tiger Tiger Softwares Software Designer and Developer VB.NET, ASP.NET, VFP

          M Offline
          M Offline
          MAP Tiger
          wrote on last edited by
          #4

          Hi guys I just have analyzed that the problem is not in this procedure but the upcoming syntaxes are throwing the error:

              Dim aDoc As IHTMLDocument2 = New HTMLDocumentClass()
              aDoc.write(strRequestHTML)
              aDoc.close()
          

          I am using this procedure to access all the elements of the downloaded HTML page and the error throws at aDoc.write(strRequestHTML) and I think it is because there are javascripts which are supposed to be loaded but the current implementation is not letting it loaded so the functions which are using them are of course left undefined which in turn throwing the error. Please help me in this regard, I would be so thankful. Regards,

          MAP Tiger Tiger Softwares Software Designer and Developer VB.NET, ASP.NET, VFP

          D 1 Reply Last reply
          0
          • M MAP Tiger

            Hi guys I just have analyzed that the problem is not in this procedure but the upcoming syntaxes are throwing the error:

                Dim aDoc As IHTMLDocument2 = New HTMLDocumentClass()
                aDoc.write(strRequestHTML)
                aDoc.close()
            

            I am using this procedure to access all the elements of the downloaded HTML page and the error throws at aDoc.write(strRequestHTML) and I think it is because there are javascripts which are supposed to be loaded but the current implementation is not letting it loaded so the functions which are using them are of course left undefined which in turn throwing the error. Please help me in this regard, I would be so thankful. Regards,

            MAP Tiger Tiger Softwares Software Designer and Developer VB.NET, ASP.NET, VFP

            D Offline
            D Offline
            dennisa
            wrote on last edited by
            #5

            since you have the string you can prepend to it: <script language="JavaScript" type="text/javascript"> <!-- function stoperror(){return true} window.onerror=stoperror // --> </script> This will suppress the javascript errors, if that is what is causing the problem.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups