I'm writing a Windows 8 application in C# and XAML that hosts a Web page in a WebView. The Web page makes calls to alert() and confirm(), but the WebView throws exceptions, saying, "'alert' is undefined," or "'confirm' is undefined." Can alert() and confirm() be enabled, or do I need to write code to emulate their normal function? And if I need to write them myself, how should I begin such an undertaking? Thank you.
Alert and confirm will not work from a WebView. You can use WebView.ScriptNotify to receive an event from your script on your page and use that event to show a dialog box using the MessageDialog class.
In your script where you want the alert ...
window.external.notify('foo');
And use the example in the WebView.ScriptNotify method in your C#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With