WKWebView strange behaviour when opening target="_blank" links on OS X - macos

I am developing an OS X wrapper around a popular web application, using WKWebView. However, when I try to open a link from the app, I get this strange behaviour:
tap on the link (the link has target="_blank")
webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures: is called
trying to extract the url from the navigationAction parameter in the delegate method above I get an empty URL
webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler: method is called with the following message parameter: "Grrr! A popup blocker may be preventing the application from opening the page. If you have a popup blocker, try disabling it to open the window."
Has anyone experienced anything similar? My idea is that they are doing something fancy with their javascript to track clicks and this is blocking the normal link behaviour.

Related

Are there any changes in the WebView related APIs in UWP or UAP Windows app?

I am having a Windows 8.1 supported app, but now it is updated to the UWP/UAP (i.e. Windows 10) app.
After updating the custom URI scheme is not working, On a button click on the web page, we were using "navto://" custom URI scheme and handling were done in a js file. The button action was bind through the anchor tag.
From this approach, we navigate our web pages forward/backward or used to send a user to a particular web page.
But now this js file is being not called on the click of the same button and a System Popup appear saying "You will need a new app to open this navto link". For reference, please have a look at the attached screenshot of the error popup. If anybody is familiar with the issue, please suggest me the solution.
Actually I followed this page to migrating the app https://learn.microsoft.com/en-us/visualstudio/misc/migrate-apps-to-the-universal-windows-platform-uwp?view=vs-2015#MigrateCSharp
And also tried other options as well by googling but I haven't got any perfect solution yet.
Thanks

High Sierra WebView blocks anchor tag navigation

I have a Mac app that displays info in a WebView. Quite an old app now and in Objective-C which I am rapidly forgetting.
The WebView contains anchor tags to allow navigation within the pages, both by clicking on links in the page displayed, or by clicking tabs in the UI which send Javascript to the WebView. In High Sierra this no longer works although it displays no error.
It appears that I need to implement isKeyExcludedFromWebScript: but my attempts to do so have failed.
Do I need to sub-class WebView? Putting isKeyExcludedFromWebScript: and isSelectorExcludedFromWebScript: in the View Controller containing the WebView doesn't work - they never get called.
If anyone has any advice or examples, I would be most grateful.
I am afraid that the answer will be to upgrade the app to use WKWebView but I was hoping for a quick work-around until I get time to do that.
Answering my own question here as I have worked out a solution.
The problem was that I was loading an HTML string into the WebView and when I tried to use internal navigation links, it didn't have a base URL to use as a prefix and so the anchor navigation never worked.
It used to work, prior to High Sierra, so there must be something new about how WebViews operate.
The solution was to save the HTML string to a temporary file and have the WebView load that file's URL instead of loading the string directly.
This applies to both WebView and WKWebView.

Facebook Like not working on Chrome

I am running the latest version of Chrome on Mac Lion. I added a FB like button to my page which works fine on Firefox but does not work on Chrome for some reason. There seems to be a quick window pop-up which tries to load and then it disappears without the "Like" taking place.
Fiddle - http://jsfiddle.net/luisp128/X7SDR/3/
I thought it might be related to this prior question, but FB said this issue was already resolved: the the popup window ("flyout") of a like button doesn't show up in a chrome extension
One thing to note is that you must be logged into Facebook within each browser for the FB buttons to appear in that browser (otherwise the buttons have no context). If not, the buttons are not shown.
So, if you're seeing this problem, open a new tab, log into FB, and then refresh the original tab - the buttons will then appear (assuming there isn't a second problem)>

Finding the origin (URL) of a dragged and dropped image/text on a cocoa application dock tile on 10.6.8

I have just started coding an application in cocoa on OSX 10.6.8. It is well underway mostly thanks to threads I have found here. For the subtle functionality I am about to explain I've looked everywhere and really have given it my best without success. Here is the situation:
There is a browser (chrome for now but the solution should be adaptable to FF and Safari at least)
There is my chrome extension
There is my desktop app
Text/images can be dragged on my desktop app which then organises these items by source.
For a file/text from finder, except a web browser, tagging the file with its file path is the desired behaviour, for a text I simply put clipboard as the source. Now the issue is that files/text dragged from a web browser should have the website they were dragged from as the source. There is an easy fix for files: I have an extension which sets a buffer with the last active url so that all I need to check when a file is dragged is whether it comes from the chrome cache to tag it with the content of the said buffer. My problem is for text. The way text dragging is handled is by using a service which I declared in the .plist, There is a similar unanswered question on SO and a technique that seems as if it could work but it is only available for 10.7 on. I also found a link where someone managed to get the url for itunes songs dragged on his application using http://www.mail-archive.com/cocoa-dev#lists.apple.com/msg17452.html
Is there a solution to see the URL of a dragged image/text that could be handled using only cocoa?
The only other option I see is using the extension to inject javascript code into all webpages for handling the 'dragenter' event and send the content of what is being dragged together with the source URL to the desktop app via a custom protocol. I'm not too keen on script injection and I sense some complication down that path as well.
In any case thank you for your help!
Chocozor.

strange behaviour with facebook page tab

i noticed a strange behaviour of facebook page tab applications, using internet explorer (i tested this only on ie8... with other browser this problem is not present).
If i put javascript code, or background sound in my application, when i goes out from page tab, my application is still running (for example sounds, or javascript activity)...
To show you the issue, i created a page....
Log in into facebook and goes to this page.
http://www.facebook.com/apps/application.php?id=252545344807399&sk=app_252545344807399
Don't click like button or anything... you can see a javascript alert each 5 seconds...
next, click on the top facebook logo. You will be redirected to your facebook home, but the url has an hash symbol, because it loads content in ajax.
Wait 5 seconds and tell me if you are still receiving javascript alert from my application in background.
Tell me please if you experience this problem.
Thanks in advance.
Giuseppe
(sorry for bad english)
.

Resources