Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Communication between .NET WebView2 client and web page using JavaScript PostMessages

When embedding a web page in your Windows desktop or mobile application usually one requires to have some kind of communication between them.  

In the old Internet Explorer days, the WebBrowser component was the way to go and a web page could send a message by writing  it on the status bar. The application would then read the status bar content and this simple mechanism allowed some kind of communication.
These days Internet Explorer and the status bar are pretty much dead and there are different ways to communicate.

The WebView2 is the current way to go (get it from NuGet) and even it it is a far more complete and complex component, upgrade is not really that hard for the basic stuff such as getting the event of document complete or location has changed.

WebView embraces new ways for interoperability between the application and the web page.
One simple way to replace the status bar messages mechanism is to use the ExecuteScriptAsync to execute JavaScript code to read information from your page. For instance, using the old hidden field trick as a message store.

But new and more powerful ways are available to have better communication.
While researching on this topic, I found a post that describes multiple ways to reach this goal, like using "postMessage" and "hostObject": Chromium WebView2 Control and .NET to JavaScript Interop - Part 2 

Microsoft also has tutorials on this:

./M6

jQuery Calendar Date Picker in Django Forms

A common problem that developers face in Django is to have a calendar picker.
Here's a simple solution how to set up jQuery Calendar Date Picker in Django.

./M6

MetaMod Placeholder Position Display Management

When using Joomla! sometimes one requires to hide some information, like a specific menu, or an entire position.

MetaMod let’s you do this in a quite easy way.
One can follow their documented technique of moving stuff from an non-existing position into the real position, or one can use a simpler strategy that does not imply having virtual positions and nor moving stuff between these virtual positions and the real position: MetaMod Position Display Management.

./M6