• 0

[VB.net] WebBrowser control does not load javascript


Question

Recommended Posts

  • 0
  On 17/05/2012 at 14:56, togerland said:

its not working on the proggie i made

You are going to have to learn to provide more data than that. Simply driving into a mechanics lot and saying; "There is a problem with my car" is not enough. Development work is about the TINY TINY details. Often it is best to give a sample of your code so others can reproduce the issue or see where you are making a mistake.

  • Like 2
  • 0
  On 17/05/2012 at 14:56, togerland said:

its not working on the proggie i made

Right... we've established this from your first post; did you load up IE and check the settings in there to ensure it has JavaScript enabled in there as suggested?

Also try helping us to help you; put up some code samples so we can 'jump into' the code and locate any possible issues there?

We can really only help you if you're willing to help yourself, otherwise it's just us flogging the dead donkey while you play with yourself in the corner.

  • 0

http://www.jeffblankenburg.com/2010/10/18/31-days-of-windows-phone-day-18-webbrowser-control/

This page wil help you:

  Quote

In case you?re planning on loading an HTML page that contains some JavaScript, you should know that scripting is disabled in the WebBrowser control by default. It?s simple to turn back on (or even toggle) using the IsScriptEnabled property of the control. Here?s two quick examples:

  • 0
  On 17/05/2012 at 18:16, James Rose said:

You are going to have to learn to provide more data than that. Simply driving into a mechanics lot and saying; "There is a problem with my car" is not enough. Development work is about the TINY TINY details. Often it is best to give a sample of your code so others can reproduce the issue or see where you are making a mistake.

Couldn't agree more...

  • 0
  On 18/05/2012 at 12:41, togerland said:

Doesnt its for C#

And your point is?

VB.Net

Browser.IsScriptEnabled = true

C#

Browser.IsScriptEnabled = true;

See how much trouble I had to go through to translate that from c# to vb. I'm tired now, I need a rest ;)

Seriously, as a developer, don't expect everything to be spelled out for you. Also, ditch VB.net its syntax is horrendous compared to c#

  • 0
  Quote

Doesnt its for C#

Dude offers you help. If you knew the first thing about the language you are "programming" (drag/dropping) in, you'd know C# and VB.net are easily substituted.

PLEASE I urge you to try and understand basic programming more before you write bad code into your app.

  • 0
  On 18/05/2012 at 12:35, togerland said:

Thanks!!!!

The only code there is webbrowser1.navigate "wherever.com" so I figured you guys knew that x

Here's another good point; In development NEVER (ever ever ever ever!) assume ANYTHING! (I'm not yelling at you, I am highlighting my point) It can be frustrating, but even a minor item can have a big effect. Development is about being very explicit. (as you are, I'm sure, quickly learning)

Have a good day.

  • 0
  On 18/05/2012 at 12:43, XerXis said:

And your point is?

VB.Net

Browser.IsScriptEnabled = true

C#

Browser.IsScriptEnabled = true;

See how much trouble I had to go through to translate that from c# to vb. I'm tired now, I need a rest ;)

Seriously, as a developer, don't expect everything to be spelled out for you. Also, ditch VB.net its syntax is horrendous compared to c#

Man I already tried that before posting my comment and it didnt work.

  • 0

So, I started up VS2010. Created a new VB WinForm project. Dropped a WebBrowser control onto the form. Added the following line of code into the FormLoad event

WebBrowser1.Navigate("pogo.com")[/CODE]

Started it up and within moments I was playing Zuma.

Looks fine to me, and that is literally all I did.

I also changed the URL to:

[CODE]WebBrowser1.Navigate("http://info.uwe.ac.uk/online/blackboard/technical/test.asp")[/CODE]

(first working result from a Google search for 'test if javascript is enabled')

Which shows that, for me anyway, Javascript is enabled.

So your initial premise is wrong. Now we need to figure out where your problem lies, for that we will need lots of info, and maybe a sample project.

  • 0
  Quote

Make a simple browser1 and command button and try going to pogo.com there will be tons of scripting errors because that control wont load javascript

STOP ASSUMING THINGS!

As said above, not yelling, just trying to get you to understand a point!

  • 0
  On 18/05/2012 at 13:42, togerland said:

Make a simple browser1 and command button and try going to pogo.com there will be tons of scripting errors because that control wont load javascript

Yes it does, so it must be something with your IE settings (which the browser control is using). The problem is on your side, with the limited information you are giving it will be hard to help you.

  • 0

Maybe I am an idiot (too), but I have a similar problem.

I created a simple program (to test).

A standard Form with a WebBrowser and a Button on it.

It does nothing more than open a page in the WebBrowser with a Internet based Radio player.

If I open the page in my IExplorer, it works fine (it plays music), but if I run the program from Visual Studio... No player, no music..

Al the items on the page load fine, but not the music player.

 

Any ideas guys?

 

Some more info:

Computer is 64bit Windows 8.1 (also tried it on a Win7 64bit)

Debugger is Visual Studio 13 Ultimate (which I have switched from 'AnyPc' to 'x86') 

 

And the code for the button is:

 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

WebBrowser1.ScriptErrorsSuppressed = True

WebBrowser1.Navigate("http://www.radioviainternet.be/q-music.php")

End Sub

  • 0

Here's an idea to check and see if it's IE or VB.

 

 

Add the website to the Trusted Zone, set the zone to Low and see if it works.

 

and for S&G Make sure your Java is up to date (yes I know JS and Java are different)

 

If that doesn't work try resetting IE to defaults.

  • 0

SOLUTION

 

I actually ran into this the first time yesterday - the Webbrower control works properly. Here's the issue:

For some reason, VB runs the control in IE7 compatibility mode. See here:

http://stackoverflow.com/questions/18668557/javascript-error-when-using-webbrowser-control-and-https-yet-it-works-in-ie

 

It all has to do with Permissions Microsoft added in IE7. Yes, you can view standard webpages and such, but as soon as it tries to run JS or anything else it tends to hit a wall because of the Permissions Microsoft added.

 

This was actually a big problem back when IE7 came out - addins for IE wouldn't work anymore, some programs that relied on IE for certain things didn't work anymore either, and the solution is the same as the one I am posting, although it was done by hand in the registry by the user for whatever app they had installed.

 

I followed a page about the issue to some code which fixes the issue here:

http://stackoverflow.com/questions/18333459/c-sharp-webbrowser-ajax-call/18333982#18333982

 

The code is in C#, but I converted it for VB.net (and have posted it at the end of this explanation).

Once I implemented this code and checked real quick, everything was fixed.

 

Just a FYI.

 

The code adds your EXE to the compatibility database and forces allowing JS and everything else.

#Region "IE Fix"
    Private Shared Sub SetBrowserFeatureControlKey(feature As String, appName As String, value As UInteger)
        If Environment.Is64BitOperatingSystem Then

            Using key = Registry.LocalMachine.CreateSubKey([String].Concat("Software\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\", feature), RegistryKeyPermissionCheck.ReadWriteSubTree)
                key.SetValue(appName, DirectCast(value, UInt32), RegistryValueKind.DWord)

            End Using
        End If


        Using key = Registry.CurrentUser.CreateSubKey([String].Concat("Software\Microsoft\Internet Explorer\Main\FeatureControl\", feature), RegistryKeyPermissionCheck.ReadWriteSubTree)
            key.SetValue(appName, DirectCast(value, UInt32), RegistryValueKind.DWord)
        End Using
    End Sub

    Private Sub SetBrowserFeatureControl()
        ' http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx

        ' FeatureControl settings are per-process
        Dim fileName = System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName)

        ' make the control is not running inside Visual Studio Designer
        If [String].Compare(fileName, "devenv.exe", True) = 0 OrElse [String].Compare(fileName, "XDesProc.exe", True) = 0 Then
            Return
        End If

        SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode())
        ' Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
        SetBrowserFeatureControlKey("FEATURE_AJAX_CONNECTIONEVENTS", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_MANAGE_SCRIPT_CIRCULAR_REFS", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_DOMSTORAGE ", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_GPU_RENDERING ", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI  ", fileName, 0)
        SetBrowserFeatureControlKey("FEATURE_DISABLE_LEGACY_COMPRESSION", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_LOCALMACHINE_LOCKDOWN", fileName, 0)
        SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_OBJECT", fileName, 0)
        SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_SCRIPT", fileName, 0)
        SetBrowserFeatureControlKey("FEATURE_DISABLE_NAVIGATION_SOUNDS", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_SCRIPTURL_MITIGATION", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_SPELLCHECKING", fileName, 0)
        SetBrowserFeatureControlKey("FEATURE_STATUS_BAR_THROTTLING", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_TABBED_BROWSING", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_VALIDATE_NAVIGATE_URL", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_WEBOC_DOCUMENT_ZOOM", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_WEBOC_POPUPMANAGEMENT", fileName, 0)
        SetBrowserFeatureControlKey("FEATURE_WEBOC_MOVESIZECHILD", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_ADDON_MANAGEMENT", fileName, 0)
        SetBrowserFeatureControlKey("FEATURE_WEBSOCKET", fileName, 1)
        SetBrowserFeatureControlKey("FEATURE_WINDOW_RESTRICTIONS ", fileName, 0)
        SetBrowserFeatureControlKey("FEATURE_XMLHTTP", fileName, 1)
    End Sub

    Private Function GetBrowserEmulationMode() As UInt32
        Dim browserVersion As Integer = 7
        Using ieKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Internet Explorer", RegistryKeyPermissionCheck.ReadSubTree, System.Security.AccessControl.RegistryRights.QueryValues)
            Dim version = ieKey.GetValue("svcVersion")
            If Nothing = version Then
                version = ieKey.GetValue("Version")
                If Nothing = version Then
                    Throw New ApplicationException("Microsoft Internet Explorer is required!")
                End If
            End If
            Integer.TryParse(version.ToString().Split("."c)(0), browserVersion)
        End Using

        Dim mode As UInt32 = 10000
        ' Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
        Select Case browserVersion
            Case 7
                mode = 7000
                ' Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.
                Exit Select
            Case 8
                mode = 8000
                ' Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
                Exit Select
            Case 9
                mode = 9000
                ' Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
                Exit Select
            Case 10
                mode = 10000
                ' Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
                Exit Select
            Case 11
                mode = 11001
                ' Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
                Exit Select
            Case Else
                ' use IE10 mode by default
                Exit Select
        End Select

        Return mode
    End Function
#End Region

In the Form's New() method, you need to add:

 

SetBrowserFeatureControl()

 

under the InitializeComponent() statement, or it won't work.

 

I hope this helps people.

  • 0

Finally figured this out. After searching and reading articles for weeks, finally got a vb.net webbrowswer1 object to open a java web page on a windows form!

 

Create a windows form

Add a webbrower object

 

Add this to the code behind the form.  Now your URL with the java should open up just fine!

 

Public Class Form1
    Sub New()
        ' This call is required by the designer.
        InitializeComponent()
 
        ' Add any initialization after the InitializeComponent() call.
        WebBrowser1.ObjectForScripting = True
        WebBrowser1.ScriptErrorsSuppressed = True
    End Sub
 
End Class
 
-LabTechDrew
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Is NAD a legitimate court? Nope, it's part of the BBB. So they can allege whatever they want. Guilt is the result of being convicted by an actual recognized legitimate court. Just sayin.
    • If it's right for someone's use case, why not? For the eye watering amount of $$$ involved in acquiring 32GB of SSDs I would want more real RAID.
    • Last chance: SQL Essentials For Dummies eBook (worth $10) free download by Steven Parker FOR DUMMIES is a trademark of John Wiley & Sons, Inc. A right-to-the-point guide on all the key topics of SQL programming SQL Essentials For Dummies is your quick reference to all the core concepts of SQL—a valuable common standard language used in relational databases. This useful guide is straightforward—with no excess review, wordy explanations, or fluff—so you get what you need, fast. Great for a brush-up on the basics or as an everyday desk reference, this book is one you can rely on. Strengthen your understanding of the basics of SQL Review what you've already learned or pick up key skills Use SQL to create, manipulate, and control relational databases Jog your memory on the essentials as you work and get clear answers to your questions Perfect for supplementing classroom learning, reviewing for a certification, and staying knowledgeable on the job, SQL Essentials For Dummies is the convenient, direct, and digestible reference you've been looking for. Claim your complimentary eBook worth $10 for free, before the offer ends today, June 17. How to get it Please ensure you read the terms and conditions to claim this offer. Complete and verifiable information is required in order to receive this free offer. If you have previously made use of these free offers, you will not need to re-register. While supplies last! Download the SQL Essentials For Dummies eBook (worth $10) for free The below offers are also available for free for a limited time: Unruly: Fighting Back when Politics, AI, and Law Upend [...] ($18 Value) FREE - Expires today 6/17 SQL Essentials For Dummies ($10 Value) FREE – Expires today 6/17 Continuous Testing, Quality, Security, and Feedback ($27.99 Value) FREE – Expires 6/18 VideoProc Converter AI v7.5 for FREE (worth $78.90) – Expires 6/18 Macxvideo AI ($39.95 Value) Free for a Limited Time – Expires 6/22 Microsoft 365 Copilot At Work ($60 Value) FREE – Expires 6/25 Natural Language Processing with Python ($39.99 Value) FREE – Expires 6/25 Excel Quick and Easy ($12 Value) FREE – Expires 6/24 The Inclusion Equation: Leveraging Data & AI ($21 Value) FREE – Expires 6/24 The Ultimate Linux Newbie Guide – Featured Free content Python Notes for Professionals – Featured Free content Learn Linux in 5 Days – Featured Free content Quick Reference Guide for Cybersecurity – Featured Free content We post these because we earn commission on each lead so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin The above deal not doing it for you, but still want to help? Check out the links below. Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: An account at Neowin Deals is required to participate in any deals powered by our affiliate, StackCommerce. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through the branded deals site.
    • Movavi Video Editor 25.9.0 by Razvan Serea With Movavi Video Editor, you can either enhance your video files with two or three simple steps, or turn them into something completely new. Create your own movies using multiple filters, transitions, and special effects: show multiple videos on one screen with the Picture in picture effect or change the background with the Chroma Key effect, imitate the camera zoom or make your video look like an old-style movie. Adjust video parameters such as brightness, contrast and colors. Stabilize shaky footage, improve video quality and remove defects. Create video presentations, tutorials or educational videos: add titles and record your own narration to create a video with voiceover. Import video from any source: TV-tuner, webcam, camcorder, or VHS. Drop multiple media files onto a timeline and let your imagination do the rest! Features at a glance: Video and audio editing on a timeline Edit, enhance videos Add background music Apply titles and effects Image quality improvement Hollywood-worthy effects High-grade titles and fades Digitize VHS tapes, record video from TV tuners Stabilize any shaky sections Support for a wide range of formats Prepare your videos for uploading to YouTube, Facebook, Vimeo, or any other website New in Movavi Video Editor 2025: Revamped timeline for easier editing The new timeline is now clearer and more streamlined. Get your projects done faster and have more fun with anything – from short vids for socials to longer family movies. Frame-precise cuts in a click Give your videos a sharper look with the new Blade tool. Easily make precise cuts and create eye-catching montages like your favorite bloggers. Pro-quality color correction Get next-level color correction with the same simplicity. Boost colors in a snap and make more viewers fall in love with your videos. AI motion tracking Enhance reality in your videos with additional moving graphics. Just click, and AI will quickly attach any photos, videos, emojis, or memes to objects in your footage. Perfect-match overlay effects Now each overlay effect has 13 blending modes to choose from. Try each of them with the press of a button and pick the one that fits your video perfectly. Best video effects – at your fingertips Create awesome videos in any style with our huge collection of professionally designed effects. Now you can try them all right away, right in the app. Movavi Video Editor 25.9.0 changelog: New Copy effects from one clip to another in a snap. Just right-click the clip → Clip effects → Copy effects. Then right-click again to paste. Try it once, and it might just become your new favorite feature. Improvements Enjoy speedier, smoother previews – now up to 20% faster! Hover over any clip to see the difference. Especially handy when you’ve got a load of clips on the timeline. Speed up editing with new keyboard shortcuts. Ctrl + Z to undo, Ctrl + scroll to zoom the timeline. You’ll find the full list in the Help menu. Fixed issues Some under-the-hood improvements that’ll be useful for faster content creation. Download: Movavi Video Editor Plus 25.9.0 | 5.1 MB (Shareware) View: Movavi Video Editor Plus Website | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Week One Done
      Rhydderch earned a badge
      Week One Done
    • Experienced
      dismuter went up a rank
      Experienced
    • One Month Later
      mevinyavin earned a badge
      One Month Later
    • Week One Done
      rozermack875 earned a badge
      Week One Done
    • Week One Done
      oneworldtechnologies earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      699
    2. 2
      ATLien_0
      272
    3. 3
      Michael Scrip
      214
    4. 4
      +FloatingFatMan
      186
    5. 5
      Steven P.
      144
  • Tell a friend

    Love Neowin? Tell a friend!