Hello,

I have a question about the webBrowser control.
It does work good to display webpages but it seems that the control have problem to
display certain webpages. (I think it has to do with javascript on the webpage).

When trying to display this webpage, it will not FULLY load everything on the webpage.

  • Trying to open the webpage in IE8 gets the same problem.
  • Trying to open the webpage in CHROME does work!

I wonder if we can modify anything for the webBrowser1 to make this work?

webBrowser1.Navigate("http://www.allslotscasino.com");

Try adding the following: this.webBrowser1.ScriptErrorsSuppressed = true;

Thanks, that line will only Ignore the error.
The thing is that I need to show the whole page which doesn´t work.

When entering the URL, I get below error, so it has to do with scripts as I understand but dont know how to solve?

"Object doesn´t suport this property or method. Do you want to continue running scripts on this page"

I can't remember if the webbrowser control supports javascript. The other issue could be with cookies.

Here's some stuff I've used:

using System.Runtime.InteropServices;
using Microsoft.Win32;
using mshtml; //internet - Reference => .NET = Microsoft.mshtml
using SHDocVw; //internet - Reference => COM  => Microsoft Internet Control
using System.Net; //HttpWebRequest, HttpWebResponse
using System.Security.Cryptography;

//It works with websites that have HTTPONLY set for cookies.
//it is necessary to use SHDocVw for this though, as   
//System.Windows.Forms.WebBrowser 
//doesn't seem to work as desired. 

//make a commom instance of WebBrowser
public SHDocVw.InternetExplorer myWebBrowser = new SHDocVw.InternetExplorer(); 

//used to pass cookies from myWebBrowser
private System.Net.CookieContainer cookies = new System.Net.CookieContainer();

//----------------------------------------
// used to get HTTPONLY cookies 
//----------------------------------------
const int INTERNET_COOKIE_HTTPONLY = 0x00002000;

[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref uint pcchCookieData, int dwFlags, IntPtr lpReserved);

Then you can use the following in the documentComplete event:

//set htmlData
HTMLDocument doc = (mshtml.HTMLDocument)myWebBrowser.Document;
string htmlData = doc.body.outerHTML;

Here is setting cookies in the NavigateComplete2 event:

private void myWebBrowser_NavigateComplete2(object sender, ref object URL)
{

    //Console.WriteLine("Navigate complete: " + URL.ToString());
    mshtml.IHTMLDocument2 HTMLDocument = (mshtml.IHTMLDocument2)myWebBrowser.Document;

    try
    {
        //add cookies to cookie container
        this.cookies.SetCookies(new Uri(URL.ToString()), HTMLDocument.cookie);
    }//try
    catch (Exception ex)
    {
        Console.WriteLine("ERROR: WebSHDocVw::myWebBrowser_Navigating (SetCookies): " + ex.Message);
    }//catch

    try
    {
        //add readonly cookies to cookie container
        this.cookies.SetCookies(new Uri(URL.ToString()), this.GetGlobalCookies(URL.ToString()));
    }//try
    catch (Exception ex)
    {
        Console.WriteLine("ERROR: WebSHDocVw::myWebBrowser_Navigating (SetCookies - Global): " + ex.Message);
    }//catch
}//myWebBrowser_NavigateComplete2

The web browser control is based on Internet Explorer. If the web page doesn't work in IE, it won't work in your WebControl either.

Okay, is there any work around fix to make it work for the WebControl or is it impossible with this control?

Chrome supports HTML5. I don't believe HTML5 was (fully) implemented in IE 8. Upgrade your browser.

HTML5 Browser Tester

If it is your website, you may be able to modify your web pages: HTML5 enabling script for IE

You could try and use WebKit.NET. This will attempt to use the same browser component that is used in Safari.

Other than that, there is the Chromium Embedded Framework, but I've found this difficult to use and produces unpredictable results (do not expect Google Chrome and Chromium to give the same output...)

Hello,
I have checked the webcontrol with the webpage i have developed, it doesnt fully loaded in webcontrol, but it does in IE. I have got script errors while loading webcontrol from visual studio- "object doesnt support property or method". But when i load the same url in IE it loaded without any error.
I couldnt sort out the issue, pls help me out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.