Is there any possibility to drop an external file onto a WebView in a Windows UWP app?
I know about :
AllowDrop="True" Drop="WebView_Drop" DragOver="WebView_DragOver"
I was able to copy files that i dragged into the clipboard and use it then on other items like displaying them as an image etc.
Besides that I don't see any way to interact directly with the webview or am i wrong? The current page the webview is showing is allowing to drop media files into it and i would like to use that feature in the webview...
WebView does not support drop event. WebView doesn’t support most of the user input events inherited from UIElement, such as KeyDown, KeyUp, and PointerPressed. A common workaround is to use InvokeScriptAsync with the JavaScript eval function to use the HTML event handlers, and to use window.external.notify from the HTML event handler to notify the application using WebView.ScriptNotify
Related
I am working on a simple app written in Nativescript.
The app has a login form that authenticates against an API, and on success loads a webview. So not that complicated.
But I would like to be able to open certain links in the default browser on the phone, and not in webview, like links to external sites.
Is it possible to "capture" all link clicks, and if the link has the target attribute set to blank, we make the link open in a external browser?
I need a solution that works both on iOS and Android.
Is this possible to do in Nativescript?
Yes, it's possible to do that in NativeScript but not with the default WebView component. I was exactly in this situation, what I did is writing a plugin that customizes default WebView in NativeScript to override the default WKUIDelegate in iOS webview & idem for Android.
For iOS, the WKUIDelegate allow to detect if any attempt to open link with target _blank with method webViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures, hence, when implementing your custom webview with this delegate allow to open link in external browser / application as you wish.
Take a look at this plugin: https://github.com/Notalib/nativescript-webview-ext to have an idea how to customize default webview.
You may use the nativescript-webview-ext plugin and use the shouldOverrideUrlLoading event to check the URL and cancel the process as needed then use the open url method in utility module to open the given url in default browser.
You can import this
import * as utils from "#nativescript/core/utils";
and then do
utils.openUrl("https://www.youtube.com/");
whenever you want to open a link (in this case youtube) in a default browser.
I have an application in which I want a webview ( WebBrowser ) to open a site, which I think is one of the, if not exclusive functions of a webbrowser.
But it does not display video's, and some of the other media is scrambled too. Any idea for that?
P.S. I am not talking about the webbrowser app, I am talking about the webview, implemented inside an aplication that is not working properly.
Generally, the media is picked up by the appropriate media handler. If the video doesn't play in the WebBrowser control, it most likely means that its format is simply not supported.
I want to detect swipe in web browser control in C# using JavaScript. I want to add some JavaScript to my web content and then if swipe occurs, call a method that loads another web content in the same web browser control.
I would like some sample code or any other suggestion to do this.
Thanks in advance
You'll need to use something to detect the swipe in javascript. I've been recommended to use touch.js but haven't had a chance to try this yet.
When you detect the swipe you can call out to native code using window.external.notify().
Be sure to set IsScriptEnabled="True" on the WebBrowser control and register an handler for the ScriptNotify event.
It's this event handler which would load the new content.
First of all, consider that gestures for a webbrowser control have it's own handlers. Now, if you don't need to pan/zoom or the like in the webbrowser control, it's not a problem.
Then you simply set the IsHitTestEnabled attribute to false, so that the web-browser no longer receives input. Then you can simply use the GestureService from the Silverlight Toolkit to handle the swipe/flick inputs.
I wrote some code on how to handle this, in another question: wp7 horizontal swipe selection
Our Mac OS application displays user interface inside WebView component.
Can we rely on the fact that WebView behaves exactly as Safari content pane on any Mac?
Can we expect the same set of plugins installed in Safari and inside WebView of our application?
In other words, is the same WebView shared by all applications on Mac OS, including Safari?
Quoted from apple docs:
A WebView object is intended to
support most features you would expect
in a web browser except that it
doesn’t implement the specific user
interface for those features. You are
responsible for implementing the user
interface objects such as status bars,
toolbars, buttons, and text fields.
For example, a WebView object manages
a back-forward list by default, and
has goBack: and goForward: action
methods. It is your responsibility to
create the buttons that would send
theses action messages. Note, there is
some overhead in maintaining a
back-forward list and page cache, so
you should disable it if your
application doesn’t use it."
A WebView uses webkit engine to render html which is what safari also uses. Hence most of the functionality will be the same.
My MacOsX has a Cocoa app with a special controller/window that employs WebKit for browsing. I just found out that the browsed content may have links that should open new browser windows. Although I set the following two declarations (see below) for my webView - nothing happens when I click those links with my specialized window. Clicking them from a regular browser would re-open a window:
[[_webView preferences] setJavaScriptEnabled:YES];
[[_webView preferences] setJavaScriptCanOpenWindowsAutomatically:YES];
Am I missing a callback implementation?
Make yourself the UI delegate:
[webView setUIDelegate:self];
And implement webView:createWebViewWithRequest:. This method needs to create and return the new WebView object and the window to display it. If you do not want to create the new view programmatically, you can use a NIB and load that instead.