javascript - Closing a webpage running in a WPF WebBrowser -


first bit of background

i'm working on web application, running within webbrowser, within wpf application.

this temporary necessity while we're gradually moving functionality web app. long that's not finished, wpf client still needed. wpf client phase out completely.

now issue @ hand

when user closes client (webpage), webbrowser should catch event , close window child to.

i found link describing need: webbrowser , javascript window.close()

alas, don't think answer described there still work, it's not possible window.close(), because i'm not 1 opening window i'm running on. browsers have (rightfully) tightened security since then.

the question

is there way trigger window close client, bubbles wpf?

thanks.

i have used webbrowser control call methods in wpf application javascript before using webbrowser.invokescript , webbrowser.objectforscripting

see msdn article how to: implement two-way communication between dhtml code , client application code see codeproject article looks might solve problem call c# method javascript hosted in webbrowser

[comvisible(true)]     public class scriptmanager     {         // variable store form of type form1.         private window _window;          // constructor.         public scriptmanager(window window)         {             // save form can referenced later.             _window = window;         }          // method can called javascript.         public void methodtocallfromscript()         {             // call method on form.             _window.close();         }     } 

from code behind of window:

webbrowser1.objectforscripting = new scriptmanager(this); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -