1

Im using this code to display a webpage in powershell

Add-Type -AssemblyName System.Windows.Forms
$URL1 = "https://tuckercraig.com/dino/"


# WinForm Setup
$mainForm = New-Object System.Windows.Forms.Form
$mainForm.Font = “Comic Sans MS,9"
$mainForm.ForeColor = [System.Drawing.Color]::White
$mainForm.BackColor = [System.Drawing.Color]::DarkSlateBlue
#$mainForm.Text = " System.Windows.Forms.WebBrowser Class"
$mainForm.Width = 960
$mainForm.Height = 700

# Main Browser
$webBrowser1 = New-Object System.Windows.Forms.WebBrowser
$webBrowser1.IsWebBrowserContextMenuEnabled = $true
$webBrowser1.URL = $URL1
$webBrowser1.Width = 700
$webBrowser1.Height = 700
$webBrowser1.Location = "50, 25"
$mainForm.Controls.Add($webBrowser1)



# Display Form
[void] $mainForm.ShowDialog()

but keep running in to these errors is there anyway to stop this? Error 1

error 2

if i press yes the elements on the page don't work.

  • Set `$webBrowser1.ScriptErrorSuppress = $true`. You should also enable IE11 emulation mode. See here: [How can I get the WebBrowser control to show modern contents?](https://stackoverflow.com/a/38514446/7444103) – Jimi Apr 21 '21 at 16:09
  • Hi, i have tried this one and had no luck im still getting these script errors – stuart harper Apr 22 '21 at 07:46
  • It's not a matter of *luck*, [WebBrowser.ScriptErrorsSuppressed](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.webbrowser.scripterrorssuppressed) set to `true` disables script error messages. Enabling IE11 emulation allows the Browser to render HTML correctly (as *correctly* as possible). If error dialogs still pop up, then you didn't set that property. – Jimi Apr 22 '21 at 10:00

0 Answers0