i have found that WebBrowser control (both Winforms and WPF) has certain javascript constructs not supported especially when they are rendered using showModalDialog / showModelessDialog calls....
This is easily reproducible...
1) Create a test html page such as C:\Temp\Test.htm
with this code..
<input type=button
onclick="showModalDialog('C:\\Temp\\Test.htm');"
value="Show Me as Modal Page." />
<BR />
<a href="javascript:alert('I am shown.')">
I should work using href.
</a>
<BR />
<a href="#"
onclick="javascript:alert('I am shown.')">
I should work using onclick.
</a>
If you load the page above using the IE browser, both hyperlinks should work. Now in the IE browser, if you you click the "Show Me as Modal Page." button, the same page opens as MSHTML dialog window and again on that both hyperlinks work.
This is expected.
2) Now create a WPF
or WinForm
app hosting WebBrowser
control sourced to "C:\Temp\Test.htm"
<WebBrowser Source="C:\Temp\Test.htm" Height="500" Width="500"/>
If you run the app and load the test page using the WebBrowser
control, both hyperlinks will work on the loaded page.
But if you load the modal window using the "Show Me as Modal Page." button, then the modal window fails to alert using the first hyperlink i.e. I should work using href.
does not appear.
Second hyperlink works as expected.
Do you guys reckon is there a workaround for the first hyperlink to work?
In my case I have no access to the page's content that I am loading using the javascript:showModalDialog()
call, so the issue fix is intended from the web browser's perspective.
EDIT
They say that FEATURE_SCRIPTURL_MITIGATION
has to be enabled for this. But it is already enabled in my registry. The MSDN continues to say ...
By default, this feature is enabled for Internet Explorer and disabled for applications hosting the WebBrowser Control. It has to be manually enabled for webBrowser control.
How to enable this for the web browser control?
MSDN :